I have one form with multiple fieldset's, each fieldset has one form element. When the form element changes then the ajax callback should get triggered. This ajax callback changes the fieldset class and returns $form.

This works perfectly when first fieldset gets changed. When I change the value in second fieldset and second ajax callback is triggered, the second fieldset gets changed but the first one is back to normal, it is like drupal forgot the changes which I made in previous callback.

If it makes any difference, i have tried with $form_state['rebuild'] = TRUE; in my ajax callback but it is not helping...

Simplified code looks somethig like this:

function ajax_form_callback_function($form, &$form_state) {               $form_state['rebuild'] = TRUE;
$key = $form_state['triggering_element']['#name'];
if ($key == 'key_1'){
    $form['some_fieldset_1']['#attributes'] = array('class' => array('new-  class'));
else if ($key == 'key_2'){
$form['some_fieldset_2']['#attributes'] = array('class' => array('new-class'));
else if ($key == 'key_3'){
$form['some_fieldset_3']['#attributes'] = array('class' => array('new-class'));
return $form;
  • 1
    Can you please provide code .I guess tht would help better in understandng ur problem. Jun 10, 2013 at 8:33
  • does anybody have any idea what am i missing here?
    – gregab
    Jun 10, 2013 at 11:31
  • Please post your code formatted with Drupal's convention in mind. You know, new lines, indentation. Now it's unreadable.
    – Mołot
    Jun 10, 2013 at 13:07


Browse other questions tagged or ask your own question.