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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Tresler’s picture

Assigned: Unassigned » Tresler
Category: bug » task

see 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.

Dave Reid’s picture

Correct, there is no hook_form_validate(). See http://api.drupal.org/api/function/drupal_prepare_form/6:

  if (!isset($form['#validate'])) {
    if (function_exists($form_id .'_validate')) {
      $form['#validate'] = array($form_id .'_validate');
    }
  }

  if (!isset($form['#submit'])) {
    if (function_exists($form_id .'_submit')) {
      // We set submit here so that it can be altered.
      $form['#submit'] = array($form_id .'_submit');
    }
  }
Tresler’s picture

Version: 5.0 » 6.x-dev
Status: Active » Needs review
FileSize
661 bytes

updating to needs review, d6, and attachign a d7 patch as well.

Tresler’s picture

Weird, 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.

jhodgdon’s picture

Version: 6.x-dev » 7.x-dev
Status: Needs review » Needs work

The 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!

Tresler’s picture

Changed 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:

IMPORTANT: only files ending in .patch or .diff will be sent for testing! For patches that apply specifically to Drupal 5 or Drupal 6, you can prefix the extension with -D5 or -D6 to prevent them from being queued for testing. For example, foo.patch and bar.diff would both be queued for testing, whereas foo-D5.patch and bar-D6.diff would not be queued for testing.

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.

Tresler’s picture

Status: Needs work » Needs review

setting status.

jhodgdon’s picture

Status: Needs review » Needs work

The 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.

Tresler’s picture

FileSize
698 bytes
701 bytes

Got 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.

Tresler’s picture

Status: Needs work » Needs review

Someday I will remember to change the status when I attach a patch. Until then, I'll post a second comment to do it. :P

jhodgdon’s picture

Category: task » bug
Status: Needs review » Reviewed & tested by the community

The 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!

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed 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.

jhodgdon’s picture

Version: 7.x-dev » 6.x-dev
Status: Fixed » Reviewed & tested by the community

Still should be committed to D6 as well. Patch above in #9 is good.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

#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!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.