This patch gives the ability to set the property #executes_validate_callback to buttons.
If a pressed button has this property set to FALSE then the form isn't validated.
With this patch forms can have buttons that cancel or add fields to the form, even if all data isn't properly filled in yet.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | form.patch | 3 KB | vanhanit |
| #4 | form.patch | 2.98 KB | vanhanit |
| #1 | form_21.patch | 3 KB | vanhanit |
| form_20.patch | 2.98 KB | vanhanit |
Comments
Comment #1
vanhanit commentedSorry, one char wrong in the previous submission.
The corrected patch is attached.
Comment #2
drummNew features only go into Drupal 7 now. Drupal 5 is the stable release, and 6 is feature frozen.
Please review and follow http://drupal.org/coding-standards.
You can also check for what button was pressed in your #validate and skip setting errors when applicable.
Comment #3
vanhanit commentedSure you could check which button was pressed but the automatic validation still takes place (the "required" validation).
I will, if I get some time, check my code and rewrite it according to the Drupal coding standards.
Comment #4
vanhanit commentedI have now completed the patch and tested it for a period of time without any problems.
Rewritten so that it follows the coding standard.
Comment #5
gábor hojtsyWhat about waiting for someone else to test as well. Setting your own patch RTBC is not considered a good idea.
Comment #6
vanhanit commentedWell, who will test this patch then?
The changes aren't that big, so places where bugs can occure are minimal.
And as I wrote before, I have used this patch on many versions of Drupal 5 and there haven't been any problems yet.
Anyhow, if someone want's to be able to override the validation on some buttons this patch allows you to do just that.
This also disables the core validation (required fields etc).
Usage:
Comment #7
robin monks commentedTabs are used in this patch, please refer to http://drupal.org/coding-standards .
Robin
Comment #8
vanhanit commentedOk, tabs replaced with spaces...
Comment #9
vanhanit commentedComment #10
Anonymous (not verified) commentedisset($form['#executes_validate_callback']) == FALSEshould be
!isset($form['#executes_validate_callback'])Is #executes_validate_callback the correct item for this? Why not change #validate (and #submit) to accept FALSE as one of its values. I think #executes_submit_callback and #executes_validate_callback are just egregious and don't give proper meaning to their function. The FAPI is already large and adding items when a value of FALSE would work just as well is hideous. Besides, the coding should be cleaner with fewer FAPI items.
Comment #11
effulgentsia commentedFor D7, we now have #limit_validation_errors, so you can set
'#limit_validation_errors' => array(): #370537: Allow suppress of form errors (hack to make "more" buttons work properly). For D8, FAPI needs major re-work: #370537-99: Allow suppress of form errors (hack to make "more" buttons work properly).Comment #12
attiks commentedThe problem with #limit_validation_errors is that it's hard for other modules to detect what the purpose of the limiting is, we need to be able to detect if we need to add clientside validation or not, simply looking at #limit_validation_errors isn't working for us
We created a new feature request as well, see #1244862: Add #skip_validation property to 'Delete', 'Cancel' buttons
Comment #13
lmeurs commented#11 works for me, thanks!
Comment #26
smustgrave commentedSearching current repo for executes_validate_callback and I don't see any instances. Believe this doesn't apply to D10
But if I'm wrong please reopen updating issue summary for D10
Thanks!