When using the AHAH module in a form the normal Drupal validation does not work. If the line

$form['items'] += dynamic_subform_get_embedded('todos_node_form', 'todos_items_subform', $node);

is removed, then the validation works again.

The AHAH module also breakes the hook_validate() function and the 'validate' in hook_nodeapi.

The also exists in version 5.x-1.5-5, and also demostration site.

Some one has a solution?

Comments

nhck’s picture

I stumbled over this too - this is because drupal won't revalidade a form with a form-id already validated. However your whole form isn't really validated completely upon using ahah.
I changed my dynamic_subform.module:
this line:
drupal_validate_form($form_id, $old_subform); // run form_values through validation checks change to this block:

  if (isset($old_subform['#token'])) {
    if (!drupal_valid_token($form_values['form_token'], $old_subform['#token'])) {
      // Setting this error will cause the form to fail validation.
      form_set_error('form_token', t('Validation error, please try again. If this error persists, please contact the site administrator.'));
    }
  }

  _form_validate($old_subform, $form_id);
beltofte’s picture

Thanks for your Niels. It fixed the validation problem, but now i have a new problem.

When i submit the form, and validation sends me back to the form with some errors, then the AHAH part of the form does not work any more. If i press "Add New Item" in the todo list, then the form just hang and the ajax wheel does not show up. The only thing i can do is to reload the page.

Do you now what is happening, and how i fix the problem?

fall_0ut’s picture

hi

the problem of validate is resolved with this patch, but if add new item after validate the ahah block

test in Todo List

without patch

1 - create new node Todo List
2 - not insert data in field required (List Title: *)
3 - submit
4 - does not appear error of field required
** the validate not working

with patch

1 - create new node Todo List
2 - not insert data in field required (List Title: *)
3 - submit
4 - appear error of fieldset required (List Title: *)
5 - click for add the new item
6 - block

gorilla_ch’s picture

Is there any update for more viable solutions to enable the validation? AHAH is a decent module and will be great if the validation is functioning too.

okazakifudosan0@blog.drupal.ro’s picture

応援しています、頑張って下さい。
岡崎市 不動産
[http://www.okazaki-fudousan.com/loan.html 岡崎市 不動産]
[url=http://www.okazaki-fudousan.com/loan.html]岡崎市 不動産[/url]

nhck’s picture

Status: Active » Closed (fixed)