Closed (fixed)
Project:
Drupal core
Version:
x.y.z
Component:
base system
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
21 Nov 2005 at 00:19 UTC
Updated:
7 Dec 2005 at 16:40 UTC
Jump to comment: Most recent file
form API has hook_form_validate_alter and hook_form_execute_alter, which allow mods to have a say in the validation/execution of any form. however, the alter functions are kind of limited if they do not provide the ability to override the validate/execute callbacks of the form itself. i've already run into this problem in a custom login module that i'm upgrading. after a discussion with adrian, this patch introduces attributes #validate_override and #execute_override, which makes this functionality possible. normal use case would be to set these to TRUE in a hook_form_alter if overriding was necessary.
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | form_submitted_1.patch | 2.64 KB | chx |
| #23 | form_submitted_0.patch | 2.62 KB | chx |
| #19 | form-validate-submit.patch | 2.07 KB | webchick |
| #18 | form_submitted.patch | 1.15 KB | hunmonk |
| #13 | form_valid.patch | 889 bytes | chx |
Comments
Comment #1
chx commentedMore power to the form API in a two line patch, that's always good
Comment #2
adrian commented+1 =)
Comment #3
hunmonk commentedfound one bug in further testing-- have to test in $form array, not $form_values array :)
just finished using this functionality in a custom login mod, and it works great!
Comment #4
adrian commentedUpon further thought ,
why not call the properties '#validate' and '#execute' , which defaults to form_id_validate and form_id_execute, but can be overridden.
This is the same way the #theme property works.
Comment #5
dries commentedIt looks to me as if this is getting more complex every minute, at the same time, it looks as if this is somewhat necessary to make extensive form modifications work elegantly. (The problem is that we have per-form validation and not per-element validation.)
I'm wrapping my head around this some more ... I don't understand what Adrian is suggesting. Adrian, are you talking about per-form properties or what?
Comment #6
hunmonk commentedadrian and i spent the morning working out this new workflow, which i believe is far superior to the old. changes this patch makes:
Comment #7
hunmonk commentedbtw, i tested this new functionality w/ logintoboggan, which makes heavy use of it. works great :)
Comment #8
chx commentedComment #9
drewish commentedi haven't tested the patch yet but i definitely prefer this to the _alter hooks.
Comment #10
chx commentedI did little work here, the patch is still hunmonk's , I just fixed a few typos and renamed #submit / $submit to form_submitted. This is a prelude to a sweeping change...
Comment #11
chx commentedComment #12
dries commentedCommitted to HEAD. Please update the documentation accordingly. Thanks.
Comment #13
chx commentedI deleted too much and this broke a "few" things like login. While it's possible to merge the per form and the per element , for now, it does not worth the bothering.
Comment #14
junyor commentedThat fixed site login for me, thanks!
Comment #15
drummThis definately helps. For the login form the username on the navigation block changes properly, but the login block remains until the page is reloaded.
Comment #16
drummAs far as I can tell, HEAD now only executes the form code when drupal_get_form() is called. This can be solved (after applying the latest patch here) for the user login block by puttng the form generation code above the test to see if the user is logged in. Unfortunately this is still too late in the page generation for the menu system to get the right permissions.
The best solution I can think of is putting the login form generation in user_init().
Comment #17
junyor commentedIsn't that the same problem as seen with file uploads in http://drupal.org/node/37605?
Comment #18
hunmonk commentedchx: don't you think it would be a good idea if the button element types also had #form_submitted attributes?? :P
currently all drupal forms are broken until this patch hits core.
Comment #19
webchickHere's a single patch which combines both required patches.
Comment #20
webchickOh and +1.. I can register/login now. :)
Comment #21
drummWorks perfectly with this patch
+1
Comment #22
chx commentedSorry -- I really do not know what happened but system module dd not get updated when the original patch went in :(
Comment #23
chx commentedFilter also needs a little love. Only form.inc got updated.
Comment #24
chx commentedRerolled so it can be applied from drupal root.
Comment #25
dries commentedCommitted to HEAD. Thanks.
Comment #26
chx commentedI just can't get this right. http://drupal.org/node/38349#comment-55931 is still needed sorry all.
Comment #27
dries commentedCommitted to HEAD. Thanks.
Comment #28
(not verified) commented