Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
When decorating the form builder or extending from it there might be the need for e.g. turn off the hook invocation, however this is not possible as the hook invocation is part of the FormBuilder::prepareForm method. Currently I need this in the autosave_form module in order to stop the hook execution on autosaving the user input only, as it is unnecessary and might be expensive.
Proposed resolution
Simply create a new protected method invokeHooks - protected or public is the question?
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#4 | 2859356-4.patch | 1.01 KB | hchonov |
Comments
Comment #2
hchonovComment #4
hchonovComment #5
dawehnerIt sounds like you have an actual usecase, right? I'm wondering whether you can explain the usecase in the issue summary. I guess this would help to understand it for the core committer crew.
Comment #6
hchonovIn the autosave_form module I've provided a decorated form builder service. On the one side I need it for the form restoration from the autosaved state, on the other side I've done couple of optimizations there, as for the autosave submissions I do not really need that the form is completely build and therefore I am preventing the execution of FormBuilder::doBuildForm as it is also expensive on large forms. The only thing that I need is the form state storage and the user input. Afterwards I do not need anything else. So currently I just have to swap the theme manager and module handler with dummy implementations in order not to fire the hooks, when autosave submission is being executed.
Comment #18
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Wonder if this is still an issue in D10?
$this->invokeHooks($form_id, $form, $form_state);
has been moved.Know I use the autosave_form and we haven't had any issues so it seems to be functional on that side?