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.
Similar to the new SystemConfigFormBase replacing system_config_form(), Crell suggested a replacement for confirm_form().
I present the creatively-named ConfirmFormBase!
The method names need a good deal of improvement. But here it is with two conversions.
Comment | File | Size | Author |
---|---|---|---|
#9 | form-1938600-9.patch | 17.36 KB | tim.plunkett |
#9 | interdiff.txt | 10.59 KB | tim.plunkett |
#7 | form-1938600-7.patch | 10.42 KB | tim.plunkett |
#7 | interdiff.txt | 4.99 KB | tim.plunkett |
#3 | confirm-form-1938600-3.patch | 9.87 KB | tim.plunkett |
Comments
Comment #1
webchickNeato.
Comment #2
Crell CreditAttribution: Crell commentedThese should have an interface to define them, then the base class just to provide reasonable defaults.
submitForm is required, so I wouldn't even define it here. The class is abstract so just go ahead and leave it out, so PHP will force implementers to add it. valdateForm I suppose makes sense to give a default-null implementation to, but submitForm should always need an implementation.
This could use a ConfirmFormInterface to define the methods and documentation, then the base class for ease of implementation.
I love how we don't need to change anything in FAPI itself for this. OO++ :-)
Comment #3
tim.plunkettOkay, this should address all of Crell's feedback, as well as improve the method names.
The interface still needs docs.
Comment #5
tim.plunkettNow I remember why I didn't bother with an interface! None of these methods need to be public, and interfaces cannot contain protected methods.
So we have two options:
Comment #6
Crell CreditAttribution: Crell commentedBah, I didn't even notice that they were protected! Yeah, then I guess no interface, just the base class. Oh well.
Comment #7
tim.plunkettThere are no explicit tests for confirm_form() at all. With one conversion done here, we have implicit coverage, but we need to add some.
This goes back to the base class, with added docs and whatnot. Interdiff is against the OP, not #3.
Comment #8
Crell CreditAttribution: Crell commentedgetPath() doesn't suggest that it's the cancellation path. I'd rename this to getCancellationPath() or similar for clarity.
Otherwise, this is looking awesome.
Comment #9
tim.plunkettGood suggestion, I made that mistake when writing tests (I briefly thought it would control the $form_state['redirect'].
I'd say this is done. None of the other confirmation forms have been converted to FormInterface yet anyway, now they can go straight into this.
Comment #10
tim.plunkettLost a tag somewhere.
Comment #11
Crell CreditAttribution: Crell commented+1 and pass the sweet potatoes.
Comment #12
webchickI had a longer review and then Chrome pinballed of death on me so I lost it. :(
Suffice to say, this patch looks awesome. I've always found confirm_form()'s "API" (big air quotes there) really confusing. It's so great to have consistency in our form definitions, despite the fact that the OO requirement of page controllers make me cranky. ;)
Committed and pushed to 8.x. Thanks!
Comment #13
xjmI think? Probably can update the existing one.
Comment #14
jibranWill there be a meta issue to convert all the confirm form?
Related #1842036: [META] Convert all confirm forms to use modal dialog.
Comment #15
tim.plunkettHere's the meta: #1945406: [meta] Convert all of confirm_form() to ConfirmFormBase
Comment #16
tim.plunkettHere's the change notice: http://drupal.org/node/1945416
Comment #17
jibranChange notice looks good thanks.