The flag entity form checkboxes show on the entity delete form for a node.
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | 2759671-25-TEST-ONLY.patch | 2.1 KB | jhedstrom |
| #30 | 2759671-30.patch | 4.98 KB | jhedstrom |
The flag entity form checkboxes show on the entity delete form for a node.
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | 2759671-25-TEST-ONLY.patch | 2.1 KB | jhedstrom |
| #30 | 2759671-30.patch | 4.98 KB | jhedstrom |
Comments
Comment #2
joachim commentedComment #3
joachim commentedComment #4
joachim commentedThis is the problem -- it's far too general. An entity type could have loads of forms with this interface. We need to check it's specifically the edit form.
Comment #5
joachim commentedPatch. Needs tests, but that can be done in #2760479: Missing tests for flags on entity form.
Comment #6
martin107 commented1) Manual testing ...
- OMG yep bug is real!
- Patch fixes bug
2) I think the new return early condition is comprehensive. and I'm happy that if I am wrong we can always adapt later.
3) Can't see any unwanted side effects.
+1 from me
Comment #7
berdirThere is no guarantee about a form mode being called edit. Might need to be configurable just like the view modes are configurable for some settings.
Comment #8
joachim commentedThat's not a form view mode, is it? It's from this bit of the entity annotation:
Comment #9
berdirForm modes and form operations more or less have a 1:1 relationship.
Just look at user as an example:
There, default is basically edit.
Comment #10
joachim commentedI was a bit confused because when I looked at my D8 site, nodes have only 1 form mode and users have 2.
Comment #11
socketwench commentedI'm really starting to not be a fan of non-field display methods...
Can we add a description to the "Display checkbox on entity edit form" checkbox, specifying that this will only work on entities with an "edit" form operation?
Alternatively, we can make this option node only, where we can be sure it will work as expected.
Comment #12
joachim commentedHow about instead of bailing if the operation isn't 'edit', we bail if it *is* 'delete'?
Comment #13
berdirWhat about checking if the form is a not an instance of ConfirmFormInterface? that works for delete and also other confirmation forms which some entity types have, e.g. payments can be refunded and that has a confirm form too.
Comment #14
joachim commentedDowngrading, as it doesn't break anything, but setting to blocker as it does look pretty rubbish.
Comment #15
rbayliss commentedHow about letting the FlagType specify what operations it should show on? Something like this.
Comment #16
berdirJust looking at core entities:
default: terms, comment, aggregator feeds, contact message.
edit: node, block_content.
That doesn't scale.
My suggestion in #13 is IMHO trivial and should work fine.
Comment #17
joachim commentedYup, let's go with #13.
Comment #18
jhedstromJust ran into this, working on implementing #13.
Comment #19
jhedstromThis implements the suggestion of checking for the confirm form interface.
Comment #20
jhedstromWith this approach, the flags still appear on the book module's 'outline' tab. Seems odd to hardcode an exception for the book module, but I'm not sure how else to approach this...
Comment #21
joachim commentedUrgh.
There's no way we can know what the actual 'edit' form is, is there?
We could say that we show the flag stuff only on both 'default' and 'edit', since that's what core uses.
(And file core bugs for D9 to standardize this stuff!!!!)
Comment #22
joachim commentedOk here's a plan:
Let's move this logic, simple as it is, to the plugin. A new method receives the form operation machine name, and returns whether the flag form element should show.
The base entity plugin says yes to the 'edit' operation, as it sounds like that's what core uses for most entities.
The user entity plugin says yes to the 'default' operation, because the user entity is being stupid.
Any custom entity types that wants something else can create a plugin and override the method.
Comment #23
berdirForm modes are extensible, book.module is a good example that is added to node by another module. In that case, you wouldn't want to have it show up, but I expect that people are adding custom form modes to edit things in different places in different ways, we do that with users for example and then you might want to have it show up.
I'm wondering if we can do something based on the form display, but since that book form extends from ContentEntityForm, it might actually have a display and just not call it.
Comment #24
joachim commentedYup, I recently made a custom entity that didn't use the 'edit' form mode at all, but two custom ones ('step1' and 'step2').
An alternative to my suggestion in #22 is that we add the same settings that we do for display modes in the flag settings.
Comment #25
jhedstromHere's an attempt to implement the approach from #22. The alternative suggestion from #24 may also make sense.
Note that even though in both 7 and 8 the config setting text for 'show_on_form' only mentions the edit form, as things are now in 7 (as well as 8) this setting also adds the element to the add form--and it works as-is too. Given this, the new method that I added checks for both add and edit operations.
I've included a test to demonstrate the current behavior. Note the only fail in the test-only patch is that the flag appears on the delete form--the add form already works.
Given this, we might also want to update the admin help text to indicate the element will appear on add and edit forms.
Comment #28
jhedstromThis is a rebase of #25.
Comment #30
jhedstromOops, re-roll missed adding a
usestatement to the closure.Comment #31
socketwench commentedNot finding anything than formatting nits, so I think this is ready to go!
Comment #33
socketwench commentedThanks everyone!
Comment #34
joachim commentedI'm going to file a 5.x issue to consider this, which ultimately might be the more flexible way to go:
> An alternative to my suggestion in #22 is that we add the same settings that we do for display modes in the flag settings.
Comment #35
socketwench commentedSounds like a good idea. Maybe we should start tagging 5.x issues?
Comment #36
joachim commentedAlready done :)