Active
Project:
AHAH helper
Version:
6.x-2.1
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
16 Mar 2011 at 11:12 UTC
Updated:
31 Mar 2011 at 09:44 UTC
Hi,
why is form validation only skipped for submissions without using a button? Can you please provide a use case for this?
I am working on a site with a form that has a 'static' part (shipping address) and an expandable part (articles). Some fields in the 'static' part are required so when the user clicks the 'add article' button of the expandable part validation kicks in which is not desired. I solved this by commenting the if clause in line 173
//if (!isset($_POST['op'])) {
...
//}
and all works as expected so I wonder why it is coded this way.
Thanks in advance for your feedback.
Best regards,
Björn
Comments
Comment #1
nightlife2008 commentedHi, try to define your static fields as
$form['user_info']['#required'] = TRUE;
$form['user_info']['#validated'] = TRUE;
This will make your fields required, but flag the form that these fields are already validated.
This will cause your AHAH submissions to skip validation for your static fields and load-in your dynamic part perfectly without returning errors on the above fields.
Once you actually submit your form, the "form_validate" function will kick in, where you can manually verify the inputs of your static fields (the ones which were flagged as "validated").
Once all validation is OK, the "form_submit" function will activate, and process your form as usual.
This scenario works for all my AHAH use cases...
/Kim