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.
Problem/Motivation
Currently, if you enable the module, none of the available paragraphs are allowed. So you're forced to click through all the layouts and enable all the paragraphs or otherwise editors will not be able to add content anymore. Assuming one would only restrict paragraphs for "Layout X" he'd still be forced to check all the other layouts as well.
Proposed resolution
To avoid this situation it would be helpful to allow all paragraph types if none are selected.
Comments
Comment #2
waluigi CreditAttribution: waluigi at Unic commentedComment #3
waluigi CreditAttribution: waluigi at Unic commentedSo I created a patch for this. One problem I faced was that you could choose the paragraph type that was chosen as the layout bundle. When either manually allowing that or now in this case it gets allowed because none others were selected, an illegal choice error popped up.
So to avoid both cases, I filtered the layout bundle out of the available paragraphs.
I'd appreciate any testing, thanks in advance :)
Comment #4
waluigi CreditAttribution: waluigi at Unic commentedComment #5
InaW CreditAttribution: InaW at Unic commentedI tested your patch. The patch works fine if I use a layout with only one region or if I have a layout with multiple regions and I don't allow any paragraphs for all the regions.
In a layout with multiple regions, if I allow some paragraphs for the first region and for all other regions I don't choose any paragraphs, then none of the available paragraphs are allowed for these regions. I assume that the correct behavior should be, that all available paragraphs should be allowed for a region where no specific paragraphs were selected in the widget for this region.
Comment #6
waluigi CreditAttribution: waluigi at Unic commentedThanks @InaW for the feedback. I did that intentionally because when a user changes something in these settings, he is aware of where and how to change things.
Enabling all paragraphs for each region if none of this region is selected is a bit too much in my opinion because one possibly want to ban all paragraphs from a layout (e.g. if you want to use it as space).
So my approach now is to check it per layout. Doing so, you are still able to deactivate a whole layout in the field settings.
What do you think?
Comment #7
InaW CreditAttribution: InaW at Unic commentedThanks @waluigi for your work. I really like your approach that you define it per layout/section. I think this is a good solution and I assume that it's easy for the user to understand how to use it. I tested it with multiple Layouts and it works fine. Well done!
Comment #9
waluigi CreditAttribution: waluigi at Unic commentedThanks a lot for testing and your feedback :) It is on dev now.