In D5, element-level validation functions received a copy of the specific element they were dealing with, AND the entire form. In D6, when #validate and #element_validate were split apart, this was apparently lost. We didn't notice, as only CCK ever really made use of both params in some of its validation edge cases.

This patch just restores the third param to the element-level validators, allowing them to examine both the specific element they're responsible for, and the surrounding context, as they did in D5.

Apologies for not catching it earlier.

CommentFileSizeAuthor
form_element_validate.patch1.49 KBeaton
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

eaton’s picture

Just a note: the best way to test that this patch hasn't broken anything is to submit a node form, then go to your account page and change your password. The two-field 'password verification' field implements an #element_validate function, and is where any problems with this code would show up. I ran it through that series of tests a few times and there were no problems, but others will want to take a look as well.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

the patch fixes regression, adds comments, and does no harm that i can detect. my forms are validating properly.

since no modules currently use this, i also used the interrogation form of patch review. here is an IRC log.

moshe_work: eaton: you have static $complete_form but you set it every time
eaton: moshe_work: complete_form only gets set the first pass through, when $form_id is set. when the function recurses, it doesn't pass along that third parameter.
moshe_work: eaton: what about multiple forms on a page?
moshe_work: could we get wrong complete_form for subsequent forms?
eaton: moshe_work: nope, that's why we want to set it whenever $form_id is passed in
eaton: if we checked whether $complete_form were set, we'd keep the same form for every subsequent validation. if we check the third param, we basically reset it each time FAPI 'externally' calls the validation system
moshe_work: right. looks good.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Good, my thinking was right as Moshe pasted. Committed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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