Posted by dreipunktnull on March 16, 2011 at 11:12am
2 followers
Jump to:
| Project: | AHAH helper |
| Version: | 6.x-2.1 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
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
<?php
//if (!isset($_POST['op'])) {
...
//}
?>Thanks in advance for your feedback.
Best regards,
Björn
Comments
#1
Hi, 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