I have a altered registration form with a check box that when checked adds few fields. The fields are wrapped in a specific div.
The callback function of check box is supposed to hide the dive when the check box is unchecked.
The adding works well but the unchecking doesn't. If I uncheck the checkbox the added fields remain there as nothing has happened. Checking it again doesn't change anything.
The weird thing is that the div is there (at least Firefox inspector sees it) and the callback function is probably fired as well (the POST is send).
I have even tried to debug it using dsm() but it doesn't show any message (no idea why).
function fm_users_more_form_user_register_form_alter(&$form, &$form_state, $form_id) {
$form['fm_first_in_firm'] = array(
'#type' => 'checkbox',
'#title' => t('Show form.'),
'#ajax' => array(
'callback' => '_fm_ajax_new_firm_form',
'wrapper' => 'firm-reg-container-div',
'method' => 'replace',
'effect' => 'fade',
),
);
$form['firm_registration_container'] = array(
'#type' => 'hidden',
'#attributes' => array('id' => array('firm-reg-container-div')),
);
}
function _fm_ajax_new_firm_form($form, &$form_state) {
if ($form['fm_first_in_firm']['#value'] == 1) {
dsm('tst1');
...
$firm_form = drupal_get_form('fm_firm_node_form', $node);
$form_wrapped = array(
'#prefix' => '<div class="firm-reg-container-div">',
'#suffix' => '</div>',
);
$form_wrapped['register_form'] = $firm_form;
return $form_wrapped;
}
else {
dsm('tst2');
return array(
'#type' => 'hidden',
'#attributes' => array('id' => array('firm-reg-container-div')),
);
}
}