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
We've been slowly converting all forms to FormInterface.
There aren't too many left, and once that is done we can remove the support for it once and for all.
Proposed resolution
Remove support for function based forms.
Remaining tasks
Wait for all forms to be FormInterface
User interface changes
N/A
API changes
All forms must be classes implementing FormInterface.
Comment | File | Size | Author |
---|---|---|---|
#30 | interdiff.txt | 1.45 KB | tim.plunkett |
#30 | form-2268761-30.patch | 22.32 KB | tim.plunkett |
#27 | form-2268761-27.patch | 20.87 KB | tim.plunkett |
#27 | interdiff.txt | 4.72 KB | tim.plunkett |
#22 | form-2268761-22.patch | 17.99 KB | tim.plunkett |
Comments
Comment #1
tim.plunkettWill postpone after this first test run.
Comment #3
tim.plunkettSee you later.
Comment #4
catchComment #5
tim.plunkettStill need issues for file_module_test_form and database_test_theme_tablesort, but the listed related issues are the remaining blockers.
Comment #6
tim.plunkettComment #7
tim.plunkettComment #8
tim.plunkettHere's all of the above issues combined with this, let's see what else breaks.
Comment #10
tim.plunkettWhoops!
Comment #12
tim.plunkett/me shakes fist at old code
Comment #14
tim.plunkett13363, 5002, 974... 0?
Comment #16
tim.plunkettComment #18
tim.plunkettWoot! This should pass now.
Comment #19
jibranIt is RTBC. Thank you @tim.plunkett for revamping the form component.
Yay!!!!
Comment #20
tim.plunkettRemoving the final hack from FormBuilder... Yay!
Uploading one last time to see it pass, and then postponing until the 7 issues go in. Then I can just retest it.
Comment #21
tim.plunkettGreat.
Comment #22
tim.plunkettRerolled after #2299427: Remove drupal_build_form() once all its usage is removed as it is deprecated
Comment #23
tim.plunkettTHIS DAY HAS FINALLY COME.
From #1913084: Introduce a Form interface for building, validating, and submitting forms in February 2013 until now.
Comment #24
BerdirAre you sure that we should do this? Doesn't this break forms that don't want to call the default methods by default? I guess it's only on the default submit and usually you have non-standard submits on specific buttons, but still?
Before, the form object versions were still inside the !isset().
I keep forgetting/avoiding it, but I'd still like to see us find a way to avoid serializing the form object and specifying it like this, because what happens is that during submit, we have two different instances, the unserialized one in those form submits and the one that was re-created. To avoid nasty stuff like https://github.com/karanpoddar/monitoring/blob/gsoc-plugin/src/SensorFor... and the corresponding one inside EntityForm.
I think supporting a way to only specify the method name for submit/validate should bring us pretty far, possibly serialize the callback_object object as a string and re-initalize it.
Comment #25
tim.plunkett#24 we absolutely do want this. #2252165: submitForm() is not called when custom form #submit handler is set was actually going to do that a different way, but this is that without the functional callbacks.
The rest of #24 is unrelated to removing this legacy code.
Before, these were optional. Now they always run.
This can be removed because of that.
All normal forms have always been given the form by reference (though it is rarely used), but batch forms were not. Now that submitForm() is always called, it must comply with the interface.
These additions are just for tests calling prepareForm() directly, its not a change for real code.
Writing a change record draft now.
Comment #26
dawehner<3 This is much better to use
I wonder whether we can use a more specific exception, at least InvalidArgument or a custom one for forms?
This is a small behavior change. Previously you seem to be able to skip the default validate/submit handling? some clarification would be cool
This is odd ... why was that not needed previously?
We need a follow up to add proper documentation for the parameters: #2303761: Move views_ajax_form_wrapper() to ViewsFormBase
Comment #27
tim.plunkett#26.2 Good point, switched the exception class
#26.3 Yes, this was intentional. Adding test coverage for that explicitly.
#26.4 This wasn't needed before because the form isn't actually validated or submitted, just prepared, so the form object wasn't needed. Now it must be present or the adding of the handlers will cause a notice.
Added https://www.drupal.org/node/2303785
Comment #28
dawehnerThank you, this is just perfect.
Comment #29
alexpottHow is this change related?
Does the docblock of FormBuilder::buildForm need to change?
Comment #30
tim.plunkett#29.1 Batch forms now have submitForm(&$form, &$form_state) executed, and need to pass $form as a reference.
Previously all batch forms provided custom submit handlers that happened to not ask for the form by reference.
#29.2 Fixed.
Comment #31
alexpottCommitted fc939d4 and pushed to 8.x. Thanks!
The method name is wrong - fixed on commit.
Comment #33
tim.plunkettThanks!