Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
forms system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
7 Oct 2012 at 11:47 UTC
Updated:
29 Jul 2014 at 21:17 UTC
Jump to comment: Most recent file
Comments
Comment #1
fubhy commentedThe attached patch is the most simple solution to that. However, I am a little bit worried that, especially in case of field widgets, we might add multiple, identical object references to the form array. Not sure how we could easily solve that or if that is even a problem.
Comment #1.0
fubhy commentedAdding related issue references.
Comment #1.1
fubhy commentedAdding link to change record.
Comment #2
fubhy commentedFixing typo in title.
Comment #4
Stalski commentedThis should be
'#element_validate' => array(array($object, 'validateName')) since the callback function or array(object,method) is an array.
Comment #5
fubhy commentedWhoops... Of course :). Thanks @stalski.
Comment #6
Stalski commentedSetting the status to have the patch tested
Comment #7
Stalski commentedTested this and reviewed it. Straight forward patch imo
Comment #8
webchickThis looks good to me, and consistent with what we're doing elsewhere in form.inc, with one exception:
It's not kosher to declare classes inside module files. They need to be in PSR-0 files/folders.
While we're at it, can you please add PHPDoc for this class?
Comment #9
fubhy commentedSure.
Comment #10
Stalski commentedJust reviewed it. Again looking good.
I think this one is good to be committed.
Comment #11
webchickAwesome, thanks!
Committed and pushed to 8.x.
We'll need a change notice for this; can likely just be added to the existing FAPI one.
Comment #12
fubhy commentedDone.
http://drupal.org/node/1734540
Comment #13
swentel commentedLooks good.
Comment #14
Stalski commentedPerfect fubhy.
Comment #15
Stalski commentedsubmissions at the same time
Comment #16
sunI'm unhappy that the existing test code was moved.
This means that we have a dedicated test for #element_validate using a class method now, but the dedicated test for a procedural function got lost.
The proper action would have been to add a second #element_validate entry for the class method and specifically assert that.
Comment #17
fubhy commentedThere are other tests that involve #element_validate and are not using method callbacks. What we are testing here is if #element_validate works. And we didn't change any #element_validate logic. We just changed is_function into is_callable. Actually I was unsure if it even makes sense to add a test for it at all. I mean.. We do not set up an array or an object in our tests to see if is_array() or is_object() works... Right? ;)
So... It doesn't matter what we do actually. And just in case - There are still other tests that use #element_validate with plain function callbacks.
Comment #18
fubhy commenteddoubleclick, sorry
Comment #20
xjmComment #20.0
xjmWoot, change records can be linked with node numbers :(