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' => 'button',
'#value' => t('Next'),
'#ajax' => array(
'callback' => 'ajax_tag_callback',
'wrapper' => 'replace_tagfield_div',
),
);
$form['tags']['question_tags'] = array(
'#title' => t("Tags"),
'#type' => 'textfield',
'#prefix' => '<div id="replace_tagfield_div">',
);
$form['tags']['table'] = array(
'#type' => 'checkboxes',
'#options' => drupal_map_assoc(array(t('SAT'), t('ACT'))),
'#suffix' => '</div>',
);
The Ajax callback
function ajax_tag_callback($form, &$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..