Problem/Motivation
Group types have a configuration that says authors automatically become members of the group they created. This is good, but the fact that it also happens for programmatically created groups is bad. Our test set-ups are overly complicated because of it and migrations are a pain in the ass.
Steps to reproduce
N/A
Proposed resolution
We need to make this a "create form only" thing, so that calls to our API do not magically behave different depending on what was configured on the group type. So the configuration option remains, but it only applies to form submission.
Remaining tasks
- Make this behavior form-only
- Write change record
- Adjust tests that relied on old behavior
User interface changes
N/A
API changes
No longer create members when group is created through code.
Data model changes
N/A
Issue fork group-3526265
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
kristiaanvandeneyndeOkay I just realized we can kill the wizard with this approach + #3499398: Create a new editor flow that does not involve wizards or custom pages
First of all we will need to remove the wizard, but not with the automatic selection of the group from the other issue. This can be done as follows:
Comment #3
kristiaanvandeneyndeWe also need to make sure that, when we're on a config form that got modified by our service, we do not call ConfigWrapperStorage->wrapEntity() during the form validation step as that actually saves a ConfigWrapper in the system for a config entity that may not get saved after all. It should be harmless if that happens, but better safe than sorry.
We should instead manually create one so that it has isNew() still set. It's only for validation purposes, so the wrapper should never get saved.
Comment #5
kristiaanvandeneyndeOkay the PoC now works for group forms.
Still need to check a bunch of stuff, but the gist of it is that whatever is configured in the relationship's form display will be shown inline in the group form. This gives some level of control over the whole thing. Probably should also hard-code language to whatever the parent form specified.
This does mean that any hook_form_FORM_ID_alter for the group relationship form will not apply here. That's an unfortunate drawback.
Comment #6
kristiaanvandeneyndeOkay, works for both entities and groups now. Also tested with all relationship fields hidden.
So this needs:
But so far it's looking very good and the code is a lot cleaner this way. No more temp store and wizard stuff.
Comment #7
kristiaanvandeneyndeManaged to work on this a bit, new status:
Option from group type to "use wizard" removed + update hookOption from relation type to "use wizard" removed + update hookComment #8
kristiaanvandeneyndeAll green! Just need to add the helper method now to easily figure out if a form was enhanced and then we are good to go.
Comment #9
kristiaanvandeneyndeRe #3 (Yes, I am talking to myself): Wrappers are automatically created in RelationshipEntityReferenceItem, so we're good.
Also, this blew up in size way more than I thought and normally I'd split this up into multiple issues. But I really don't feel like with the little time I have to spend on it and I'm basically alone at this, so I've decided to let this one slide. The change records will make things clear.
Let's get this show on the road
Comment #11
kristiaanvandeneynde