Problem/Motivation
The ui_patterns_element_info_alter() implementation adds WysiwygWidget::textFormat as #pre_render callback for all text_format elements.
Unfortunately this breaks core's functionality to limit a text fields allowed text formats. In my case, there is only Full HTML allowed, but with ui_patterns module installed, the text format selection is visible again and also allows to select Plain text.
Additionally the code of WysiwygWidget::textFormat looks quite outdated and e.g. names Drupal\filter\Element\TextFormat::processTextFormat() which does not exist anymore (it is TextFormat::processFormat() now and has a lot more code to allow limiting formats).
Steps to reproduce
- Make sure
ui_patternsmodule is not installed - Add a
Formatted textfield to any fieldable node type and only allow e.g. a single text format for that field in its settings - Go to the entity form of that entity type and see the formatted text field with no
Text formatselection available (or only allowing to select one of the allowed text formats, if more than one was allowed in field config) - Install
ui_patternsmodule - Go to same entity form and see the formatted text field WITH
Text formatselection and too many options (not only the ones, that were allowed in field config)
Proposed resolution
- Check if code in
WysiwygWidget::textFormatis needed at all - Fix or remove code, so allowed formats settings are also respected, when
ui_patternsmodule is installed
Remaining tasks
- Create issue fork and MR to fix this issue
User interface changes
n/a
API changes
n/a
Data model changes
n/a
Issue fork ui_patterns-3465517
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
hctomFixed some typos in the issue description ;)
Comment #3
pdureau commentedThanks a lot Tom for using an early version of UI Patterns 2.x and helping us making the module ready for beta.
Indeed. It was not caught by our quality tools because it was in a comment.
@just_like_good_vibes can you have a look? It seems this is the follow-up of #3456083: [2.0.0-alpha3] WysiwygWidget bug with one text format
Comment #4
pdureau commentedComment #5
just_like_good_vibesHello, yes i will take the issue. Thank you for reporting the bug hctom.
i will try to fix this very soon.
Comment #6
hctomYou're welcome - I'm currently evaluating the state of ui_patterns and I am quite impressed so far! ;) Thanks a lot and keep up the good work.
Comment #8
just_like_good_vibesthank you for your nice comment :)
i have posted a fix, please review.
The reason why. we use pre-render, is that we override the default behavior proposed by the form element to always propose the option "Plain text" and to allow all site-wide text formats.
Maybe we could renovate that in the future and simplify.
please review if you have some time to do it
Comment #9
hctomThanks for your fast response and fix. This looks good to me. In my node forms etc. the
Text formatselect element is gone again, when only a single text format is allowed and theWysiwygsource still has theText formatselect element available.I'd also say moving the #pre_render callback assignement to the actual source plugin is definitely better, so that code does not run for all
text_formatelements.Thanks a lot again and: RTBC from my side ;)
Comment #10
just_like_good_vibesthanks for the quick review. Indeed this was clearly a bug the way it was coded.
And yes we keep the select list in the
Wysiwygsource form, even if only one format is available.And we actually have two possible selections with the "Plain text" :)
Comment #12
just_like_good_vibesComment #13
pdureau commented