Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
node_type_form_validate() http://api.drupal.org/api/function/node_type_form_validate/5 states that it is an "Implementation of hook_form_validate()". Unfortunately, hook_form_validate() does not exist, only hook_validate() does.
Comment | File | Size | Author |
---|---|---|---|
#9 | 336627-D6.patch | 701 bytes | Tresler |
#9 | 336627-D7.patch | 698 bytes | Tresler |
#6 | d7-hook_node_type_validate_documentation.patch | 697 bytes | Tresler |
#6 | d6-hook_node_type_validate_documentation_0.patch | 700 bytes | Tresler |
#4 | d6-hook_node_type_validate_documentation.patch | 664 bytes | Tresler |
Comments
Comment #1
Tresler CreditAttribution: Tresler commentedsee this http://api.drupal.org/api/file/developer/topics/forms_api_reference.html... in this case, 5 and 6 are the same.
You are correct, that there is no hook_form_validate() per se. This is an implementation of a validation function called by forms_api.
Specifically, as I understand it, drupal_process_form() calls drupal_validate_form() which executes any functions in the #validate key of the $form array.
http://api.drupal.org/api/function/drupal_validate_form/6
I'll roll a patch to fix the language soon. However, nothing is broken, so changing this to a task.
Comment #2
Dave ReidCorrect, there is no hook_form_validate(). See http://api.drupal.org/api/function/drupal_prepare_form/6:
Comment #3
Tresler CreditAttribution: Tresler commentedupdating to needs review, d6, and attachign a d7 patch as well.
Comment #4
Tresler CreditAttribution: Tresler commentedWeird, internet ate my first comment. Like Dave Reid says, there is no hook, but you also don't always need to use #validate in the $form array, you can just create my_form_id_validate () and it will be called automatically.
Anyway, updating language to mirror other core _validate functions
Validate node_type_form submissions.
instead of Implementation of hook_validate() which is incorrect
d6 patch attached.
Comment #5
jhodgdonThe patch in #3 looks fairly good to me for Drupal 7, and the patch in #4 looks fairly good to me in Drupal 6. The only thing I would change is to say node_type_form() rather than node_type_form without the parentheses, because that will generate a link to the node_type_form() function (which creates the form that is being validated). Actually, even better would be:
Validates the node type form generated by node_type_form().
because this would put it in plain English as well as giving a link.
Also, when you submit a patch for D6, you should call it something like 336627-D6.patch rather than D6-336627.patch -- check the help text under the "attach new file" field below.
I also changed the Drupal version field to D7.... Standard practice is to patch/review/commit in D7, then backport to D6.
Thanks!
Comment #6
Tresler CreditAttribution: Tresler commentedChanged language to "Validate the content type submission form generated by node_type_form()." As I thought repeating the same thing was more redundant than plain.
Added the brackets to create the link. +1
As for the renaming, I am a bit confused by the help text and the advice:
First off, the example we give is a suffix not a prefix as the text indicates. Which do we mean?
Second, Why would I want a patch I submit not to be queued, as you indicate? Don't I want the bot to auto-test patch application for me? Am I missing something?
New patches attached.
Comment #7
Tresler CreditAttribution: Tresler commentedsetting status.
Comment #8
jhodgdonThe auto-testing bot only runs and tests in Drupal 7, so you usually only want to submit Drupal 7 patches for testing. Normally, Drupal 6 patches will fail in testing; in this case, it happened that the tests passed on the D6 patch, because the patch (being essentially the same as the D7 patch) actually worked in D7.
So you would normally name your D6 patch file 336627-D6.patch, and your D7 patch file 336627.patch, so that the testing bot would ignore the D6 patch.
Anyway, that aside, the current style guidelines for function headers are that the verb should be third person: Validates not Validate. See http://drupal.org/node/1354
Other than that, I like the wording you chose.
Comment #9
Tresler CreditAttribution: Tresler commentedGot it, although I still think that wording should be changed from prefix to suffix :D I'll let it slide for now.
Two new patches attached with the naming change and the s added.
Comment #10
Tresler CreditAttribution: Tresler commentedSomeday I will remember to change the status when I attach a patch. Until then, I'll post a second comment to do it. :P
Comment #11
jhodgdonThe wording below the file upload field says "you can prefix the extension" -- ie. instead of .patch, use -D6.patch. So it is a prefix on the file extension. Anyway, obviously it was confusing! You can file an issue to get this changed -- probably the right Project would be "drupal.org webmasters" or something like that.
I also changed this back to a bug report. It is/was a bug in the documentation.
Anyway, I like your current patches and I think they are ready to commit to D7 and D6. If someone commits to D7, please change version to D6 and leave as RTBC. Thanks!
Comment #12
webchickCommitted to HEAD.
In another issue, it might be worth coming up with common conventions for form validation and submission handler PHPDoc, so you can easily tell what they are.
Comment #13
jhodgdonStill should be committed to D6 as well. Patch above in #9 is good.
Comment #14
Gábor Hojtsy#395132: documentation: poll_node_form_submit() had a very similar fix, but that was a $form_id . 'submit' type of callback, not a validate one. Nonetheless, I've committed this fix to D6 as well. Agree with @webchick that we'd be better coming up with a general documentation scheme for these functions to reference their forms. Maybe include @see form_function_name()?
Committed to Drupal 6, thanks!