Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
forms system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
30 Jan 2013 at 15:43 UTC
Updated:
29 Jul 2014 at 21:50 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
tim.plunkettdrupal_get_callback_form.patch queued for re-testing.
Comment #3
damiankloip commentedMaybe this param should be $callable instead? Just for clarity? or maybe not, I'm not sure on that :) Atleast maybe this could reference that the parameter is the same as that of call_user_func_array?
Comment #4
tim.plunkettWell the 'callable' type hint is a PHP thing (see http://php.net/manual/en/language.types.callable.php or http://php.net/manual/en/function.is-callable.php) and http://php.net/call_user_func_array just happens to accept those.
I named it $callback because that's what the $form_state key is. Maybe that should be changed to 'callable', but I think that consistency is more important here.
(We don't often see
@param string $string)Comment #5
damiankloip commentedYeah, I guess people can look up callables if they need to.
Consistency is good. I think the patch is just fine how it is now.
Comment #6
dawehnerThis looks pretty good. Should we provide some test for that?
Comment #7
tim.plunkettYes, here is a test. Not bothering to upload a tests only, since it will just be "function does not exist"...
Comment #8
chx commentedI dunno, we used http://api.drupal.org/api/drupal/core%21modules%21system%21system.api.ph... before for specifying callbacks...
Comment #10
tim.plunketthook_forms() does not help with non-static methods because you do not have the object on hand.
Consider field_ui_field_overview(), which has to create a new object for whatever entity type it is passed, and then specify that object and its method as the callback.
Comment #11
tim.plunkettStupid mistake.
Comment #14
tim.plunkett#11: form-1903176-11.patch queued for re-testing.
Comment #16
Crell commentedThis seems like a reasonable small cleanup. If nothing else it shortens a few code blocks elsewhere by reducing duplication.
Comment #17
catchLooks fine to me as well Committed/pushed to 8.x.
Seems reasonable to backport.
Will also need a change notice.
Comment #18
chx commentedHell no. Sorry for dropping the ball but step one is rolling this back and making something better.
Comment #19
chx commenteddrupal_get_form($this). Make an interface. Methods:formGetId. Default toget_class($this)I think.formformValidateformSubmitdrupal_get_form(array($this, 'foo')). Methods:formFooGetId. Default toget_class($this)I think.formFooformFooValidateformFooSubmitComment #20
Crell commentedHm. If we were to go with chx's proposal, I'd suggest restricting it to one form per object. Multiple forms just gets messy.
Note that allowing an object there would mean some forms could not be used as declared callbacks (from menu items/routes, etc.) as those need to be static strings. That may be OK, but does create two classes of form (no pun intended).
Comment #21
dawehnerhttp://drupal.org/node/1910136 is a small change notice.
Comment #22
chx commentedI talked to Daniel and this was an x-post and I unpublished the change notice for now.
Comment #23
tim.plunkettI do not think that this should be backported after all.
To follow-up with chx's request in #19, I've opened #1913084: Introduce a Form interface for building, validating, and submitting forms.
I'm republishing the change notice.
Comment #24.0
(not verified) commentedUpdated issue summary.