My project has a special flag with an entity reference field in it to nodes of a content type I'll call here "bucket."
How it works:
- The flag "add to bucket" appears on nodes of type Article
- If the user wants to bucket the node, they click the 'add to bucket' flag
- The 'add to bucket' flag is configured to display a dialog (at the moment, not modal)
- The dialog allows them to select a bucket; on submission of the dialog, the flagging is created with a relationship to the selected bucket
All of that works great (views allows the user to see Articles in each bucket)
The problem arises when the user decides to remove the flagging from the node.
Flag module uses the same dialog, only with a 'remove' button added to it. Since it's the same dialog used to add the flagging, it has the entity reference field with the list of buckets... but this is meaningless. Clicking 'remove' deletes the flagging regardless of what 'bucket' it's related to.
The dialog also has a "save" button on it that doesn't make sense in that context.
I'd like users to not see the entity reference field when removing the flag... and also not see the save button.
Option 1: maybe there is a setting in the flag configuration for this and I am going to facepalm . . . but I am not seeing the setting, if it exists. (Fatigue blindness? I have done it before!)
Option 2: use CSS to hide those two elements. Problem: there does not appear to be classes to distinguish the removal context from the add context. Maybe I'm missing something there? I can see that in my theme form.html.twig is handling individual form elements, but I don't see what template is generating the dialog. With that info, maybe some logic can go into the template to create some classes for the unflagging?
Option 3: get it to use a different form for the unflagging. ... How to do that?
Maybe there's a module that can do this, or a combination of them? I haven't found one.
If I'd need to code a module, any advice on the general approach? (Note: I've coded maybe two tiny modules before, mostly cut and paste, so... skill level for that is probably "below novice." So use small words, lol)