Empty submitting values in ajax added form
/**
* Page callback for test_module_module_page
*/
function test_module_module_page(){
$test_form = drupal_get_form('test_module_test_form');
return render($test_form);
}
function test_module_test_form_submit($form, &$form_state) {
drupal_set_message(t('Submitting values: @values', array('@values' => var_export($form_state['values'], TRUE))));
}
/**
* Form for page
*/
function test_module_test_form($form, $form_state) {
$form['#prefix'] = '
';
$form['#suffix'] = '
';
$form['first'] = array(
'#type' => 'textfield',
'#title' => t('first textfield'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'submit ajax',
'#ajax' => array(
'callback' => 'test_module_preview_form_ajax',
'wrapper' => 'test-form-ajax-wrapper',
),
);
return $form;
}
/**
* Ajax callback for test FORM
*/
function test_module_preview_form_ajax($form, &$form_state) {
$form['ajax_form'] = array(
'#type' => 'fieldset',
'#title' => t('This is form delivered via AJAX'),
);
$form['ajax_form']['second'] = array(
'#type' => 'textfield',
'#title' => t('second textfield'),
);
$form['ajax_form']['submit'] = array(
'#type' => 'submit',
);