I was struggling for 8 hours today with a form that wasn't validating although the required fields were set to required => FALSE and although they were actually filled in.
After applying several of the other patches provided in this issue queue to fix other small bugs which occured I stilll could not fix the validation error. In the end I found in one of the example modules posted that the author had set the '#tree' => FALSE in the initial wrapper. I tried this approach and voilá, everything worked.
I just thought I'd post this here if anyone else has the same issue. I do however have some concerns of why '#tree' is set to TRUE in all the examples I've seen. Hopefully this solution doesn't break anything essential.
Thank you for a fantastic module, I would have spent weeks trying to figure out this AHAH stuff if not for your fantastic effort of putting this together.
span
Comments
Comment #1
span commentedJust thought I'd add a possible reason for this for any other AHAH noob like me running into the problem.
I was using hook_form_alter to perform the changes to the form and the form was being generated in another module that did not use #tree => TRUE. Perhaps this could have been the problem since when I alter the form and set #tree => TRUE the name attribute on the fields change around and the field that's supposed to be required throws an error because the field which is actually filled in has another name that follows the #tree structure.
Just my thoughts, could be off by miles but hopefully it will help someone.
Comment #2
FranciscoLuz commentedI was having similar issue with node-form. All the required cck fields were spiting a form_set_error inside the wrapper.
To get around this I have added a drupal_get_messages('error') as shown below:
drupal_get_messages('error');
What this actually does is a clean up in the message stack only when the form is being rebuilt.
Instead you could as easily do the same thing at hook_form_alter in your custom module.
Comment #3
erikwebb commentedComment #4
jerome72 commentedYeah! Thank you so much FranciscoLuz! I spent many hours searching and googling this issue and your solution in #2 did the trick!
I just put drupal_get_messages('error'); at the end of my hook_form_alter and the validation errors disappeared!
Cheers