Currently, the 'checkbox on entity form' feature is handled by:
- hook_form_alter() for nodes,
- hook_field_attach_form() for everything else
There are several reasons to change this:
- it's not a very good pattern to handle exceptional cases like that
- in fact, it's not much of an exceptional case at all. We'd need to do a proper diff of the two chunks of code, but at a glance it looks like the the only difference is the vertical tabs for nodes
- hook_form_alter() is called for every single form on the whole site. Removing this would be good.
I suggest that we add a method to the flag class which is called in hook_field_attach_form() after the basic work to the form, and allows specific flag classes to alter the form -- call it something ilke $flag->entity_form_alter(). In the base class this would do nothing, and in the node class it would take care of the stuff that's special for nodes.
(Tagging as 'Intermediate' which I assume is the next step up from Novice?)
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 1784402.flag_.fold-hook-form-alter.patch | 6.04 KB | joachim |
Comments
Comment #1
joachim commentedComment #2
joachim commentedIn the face of resounding silence, the patch still applies, works for me, we're still in alpha :)
Issue #1784402 by joachim: Changed handling of node forms to be done generically in hook_field_attach_form() instead of hook_form_alter().