Problem/Motivation
When creating/editing a node, I'd like to only show the Domain Access field in the advanced node settings, not the "Send to all affiliates" field. However, in this case neither shows.
This is because the code which moves the fields into the advanced node settings checks for the presence of _both_ fields, not just either one.
Steps to reproduce
Enable Domain Content. At /admin/config/domain/domain_access check Move Domain Access fields to advanced node settings. Go to Manage form display on a content type, and enable both Domain Access and "Send to all affiliates" fields. Verify that when creating/editing a node of that content type, both fields show up in the advanced node settings.
Then go back to Manage form display and disable the "Send to all affiliates". Go back to the node add/edit form; neither field is visible now, but it's expected to see the Domain Access field.
Proposed resolution
Change the if statement in domain_access_form_node_form_alter() to check separately for the presence of each field.
Patch to follow.
| Comment | File | Size | Author |
|---|
Issue fork domain-3202266
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
burningdog commentedComment #3
burningdog commentedPatch attached.
Comment #4
agentrickardPatch looks fine. Did you remove one of the fields manually? That's not expected behavior.
Comment #5
agentrickardPatch needs work. You cannot bail out with a return before loading the hidden fields.
These are always required, regardless of the tab status.
Also const TRUE is always uppercase.
Comment #6
agentrickardI am surprised that we don't have a test that makes this patch fail -- which is probably because in our tests we always have both fields, so the early bail out condition is never met.
Comment #7
burningdog commentedI didn't remove one manually, but I don't want to display the "Send to all affiliates" option to my users, so that field isn't enabled in "Manage display" for my content type.
I've incorporated your suggested changes in a new patch.
Comment #8
agentrickardThanks!
Comment #9
agentrickardComment #10
ericras commentedI've been using this patch in production for the same use-case as the submitter. Works for me and corrects the issue.
Comment #11
dqdThanks for the report but that's not a full review to me for RTBC.
Good finding @burningdog. And +1 for reporting and the patch. While I do not have an issue with it since I expect that all or none of the fields in the domain field group are visible, I see the point of that if it is visible in this way in Manage form display, it should have an effect working with it individually.
Nitpicking: Before we had one comment at 260 but now we have 3 exact similar comments on 261,269,274 while all the following code differs. I recommend to change that by reflecting the difference in each situation.
Comment #12
burningdog commentedGood point re: the nitpick. I've removed the comment duplication and put it at the start of the entire block of logic.
Comment #13
burningdog commentedComment #14
antoniya commentedRerolled the last patch as it was failing to apply with the latest module version.
Comment #15
didebruReroll against 2.0,x.
Comment #16
didebruComment #19
dieterholvoet commentedI started a MR with a version of the patch rebased on 2.x and with some improved readability.
Comment #20
agentrickardI will review this after finishing #3458055: Configure and fix PHPStan issues
Comment #23
mably commentedComment #24
mably commented