I have using Drupal 6 and AHAH to customize my node form. For ahah I use this code:
function mymodule_subtopic_type() {
$output = '';
$form_state = array('storage' => null, 'submitted' => false, 'rebuild' => true);
$form_build_id = $_POST['form_build_id'];
$form = form_get_cache($form_build_id, $form_state);
$args = $form['#parameters'];
$form_id = array_shift($args);
$form_state['post'] = $_POST;
$form['#post'] = $_POST;
$form['#programmed'] = false;
$form['#redirect'] = false;
drupal_process_form($form_id, $form, $form_state);
$form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
$topic_form = $form['topic_wrapper'];
unset($topic_form['#prefix'], $topic_form['#suffix']);
$output .= theme('status_messages');
$output .= drupal_render($topic_form);
drupal_json(array('status' => TRUE, 'data' => $output));
}
New form elements are rendered fine, but I get status messages:
How to stop validation after ahah call?
Solution from do: http://drupal.org/node/831900#comment-3124386
Add this function:
function _ahah_helper_disable_validation(&$form) {
foreach (element_children($form) as $child) {
$form[$child]['#validated'] = TRUE;
_ahah_helper_disable_validation(&$form[$child]);
}
}
and call it before drupal_process_form($form_id, $form, $form_state);
Another option I am trying is to detect the AHAH button click and return from the validation hook without processing if it's not my 'real' submit button. I was using the $form_state 'op' value, but just learned that only seems to work on Chrome.
Just another idea.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.