Cannot change checkboxes options in drupal form using AJAX callback I am trying to apply the #options value of a checkboxes in a form inside a Ajax callback.  

Even after using $form['tags']['table']['#options'] = $final; the value in the form is not changing.  

I have tried printing the #options value in the watchdog and the value seems to have changed.
But it is not getting reflecting on the form page.  

The form field which needs to be updated  

$form['tags']['ask_button'] = array(
      '#type' =&gt; 'button',
      '#value' =&gt; t('Next'),
      '#ajax' =&gt; array(
        'callback' =&gt; 'ajax_tag_callback',
        'wrapper' =&gt; 'replace_tagfield_div',
      ),
    );
$form['tags']['question_tags'] = array(
      '#title' =&gt; t("Tags"),
      '#type' =&gt; 'textfield',
      '#prefix' =&gt; '&lt;div id="replace_tagfield_div"&gt;',
    );
$form['tags']['table'] = array(
      '#type' =&gt; 'checkboxes',
      '#options' =&gt; drupal_map_assoc(array(t('SAT'), t('ACT'))),
      '#suffix' =&gt; '&lt;/div&gt;',
    );  

The Ajax callback  

function ajax_tag_callback($form, &amp;$form_state) {
\\some code\\
  $final = drupal_map_assoc(array(t('SAT'), t('ACT')));
  $form['tags']['table']['#options'] = $final;
  $form['tags']['question_tags']['#value'] = $tag_names;
\\returned the form here
 return $form['tags'];
}

Even after returning the form field, my form is not getting updated. Please suggest me a solution..
* Update using new code *

Form definition:

$form['tags']['ask_button'] = array(
  '#type' =&gt; 'button',
  '#value' =&gt; t('Next'),
  '#ajax' =&gt; array(
    'callback' =&gt; 'ajax_tag_callback',
    'wrapper' =&gt; 'replace_tagfield_div',
  ),
);
$form['tags']['values'] = array
(
  '#prefix' =&gt; '&lt;div id="replace_tagfield_div"&gt;',
  '#suffix' =&gt; '&lt;/div&gt;',
);
if(isset($form_state['values']))
{
  $final = drupal_map_assoc(array(t('SAT'), t('ACT')));
  $form['tags']['values']['question_tags'] = array(
    '#title' =&gt; t("Tags"),
    '#type' =&gt; 'textfield',
    '#value' =&gt; $tag_names, // Note - you didn't show how this is created
  );
  $form['tags']['values']['table'] = array(
    '#type' =&gt; 'checkboxes',
    '#options' =&gt; $final,
  );
}
else
{
  $form['tags']['values']['question_tags'] = array(
    '#title' =&gt; t("Tags"),
    '#type' =&gt; 'textfield',
  );
  $form['tags']['values']['table'] = array(
    '#type' =&gt; 'checkboxes',
    '#options' =&gt; drupal_map_assoc(array(t('SAT'), t('ACT'))),
  );
}


And your ajax callback will look like this:

function ajax_tag_callback($form, &amp;$form_state) {
  return $form['tags']['values'];
}


* Original response *

Not enough information provided to say for sure what your problem is, but it's likely one of these:

Problem 1:

You are making changes to the form in the ajax callback. You cannot do this. Here is how the form API works.

1) Form is generated

2) Form is cached on server

3) Form is sent to user

4) User initiates some ajax

5) Values are sent to server

6) Form is rebuilt, with submitted values

7) New form is cached on server

8) Form is sent to ajax callback

9) Relevant values are returned from ajax callback

10) Drupal sends data to browser, and the new parts of the form are injected into the page

11) User submits form

12) Drupal checks submitted values to the cached form, to see if the received values match the cached form, giving an error if they don't. This is the major strength of the Form API.

Step 7 and 8 are the key points here - the form has already been cached before it is sent to the ajax callback. So any changes you make won't be part of the cache causing errors.

Problem 2

You don't have a #prefix set on $form['tags']. You have only set the suffix. You need to provide a wrapper with your #ajax definition (which you didn't show us), so maybe the wrapper you have provided does not exist.