I've created a form that has two selections on it. One to generate a separate form using AHAH. After the user selects a form, the form appears and then the user can enter data.
The problem occurs when the user submits the form. On final submission, the user is then redirected to the js callback page set in the AHAH array and data from the drupal_json function is displayed.
What's going on and how can I fix it?
for instance: (we'll say, for brevity's sake, menu callbacks, etc. are understood)
function my_module_form() {
$form['myform'] = array(
'#type' => 'submit',
'#value' => t('Go To Term Form'),
'#ahah' => array(
'event' => 'click',
'method' => 'replace',
'path' => 'admin/my_module/js',
'effect' => 'fade',
'wrapper' => 'myform',
),
);
}
function my_module_js() {
return drupal_json(array('status' => TRUE, 'data' => drupal_get_form('my_module_term_form')));;
}
function my_module_term_form() {
$form['term_form'] = array(
'#type' => 'select',
'#title' => t('example'),
);
$form['term_submit'] = array(
'#type' => 'submit',
'#value => t('Submit'),
);
$form['#submit'] = array('my_module_term_form_submit');
}
Now, with this basic setup, it seems as though after the form is rendered by the AHAH action it's already cached and "submitted" before any values are placed in the fields. So when the user submits nothing works right.
Anybody?
(cntlscrut)
Comments
Issue
If this is still a problem for you see #591696: Problem with various AHAH forms and validation.