Download & Extend

Problem with multiple checkboxes in single form using AHAH Helper

Project:AHAH helper
Version:6.x-2.2
Component:User interface
Category:support request
Priority:critical
Assigned:Unassigned
Status:active

Issue Summary

Hi,
I am developing my application in Drupal 6 and I am using AHAH Helper module in form. Below is my code but I am facing problem in this code with check boxes. I am getting the right result but the result of checked check boxes is merged with both of the array of check boxes even though the resulting array is different for both. I want separate array for both of the result. How can I do this?

function events_details_form($form_state) {
  $form['event_details'] = array();
  $form['box-email'] = array(
    '#type' => 'markup',
    '#prefix' => '<div id="box-email">',
    '#suffix' => '</div>',
    '#value' => ' ',
    '#tree' => TRUE,
  );

  $form['box-sms'] = array(
    '#type' => 'markup',
    '#prefix' => '<div id="box-sms">',
    '#suffix' => '</div>',
    '#value' => ' ',
    '#tree' => TRUE,
  );
  ahah_helper_register($form, $form_state); 
  $query = "SELECT * FROM {node}";
  $rs = pager_query($query,5,0,NULL);
  $status = array();
  if ($rs) {
    while ($data = db_fetch_object($rs)) {
        $options[$data->nid] ='';
        $form[$data->nid]['nid'] = array('#value' => $data->nid);
        $form[$data->nid]['vid'] = array('#value' => $data->vid);
        $status[] = 'false';
    }
  }
  $form['email'] = array(
    '#type' => 'checkboxes',
    '#options' => $options,
    '#default_value' => $status,
    '#ahah' => array(
        'path'    => ahah_helper_path(array('box-email')),
        'wrapper' => 'box-email',
      ),
  );

$form['sms'] = array(
  '#type' => 'checkboxes',
  '#options' => $options,
  '#default_value' => $status,
          '#ahah' => array(
            'path'    => ahah_helper_path(array('box-sms')),
            'wrapper' => 'box-sms',
            ),
  );

  $form['update_usage'] = array(
    '#type'  => 'submit',
    '#value' => t('Update Paymentgateway'),
    '#submit' => array('ahah_helper_generic_submit'),
    '#attributes' => array('class' => 'no-js'),
  );

  if(isset($form_state['storage']['email'])) {
    $form['message'] = array(
      '#value' => checked_email($form_state['storage']['email']),
      '#attributes' => array('class' => 'testing')
    );
  }

  if(isset($form_state['storage']['sms'])) {
    $form['message'] = array(
      '#value' => checked_sms($form_state['storage']['sms']),
      '#attributes' => array('class' => 'testing')
    );
  }

  $form['pager'] = array('#value' => theme('pager', NULL, 5, 0));
  return $form;
}

function checked_email($checked_email_values) {
  foreach($checked_email_values as $key => $val) {
    if($val)
      drupal_set_message($key.$val);
  }
  return $checked_email_values;
}

function checked_sms($checked_sms_values) {
  foreach($checked_sms_values as $key1 => $val1) {
    if($val1)
      drupal_set_message($key1.$val1);
  }
  return $checked_sms_values;
}

Comments

#1

Can anybody help me for this problem??

nobody click here