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.
As per existing code in src/WidgetSettings.php
// @todo: find a more flexible way to specify these settings, not hardcoded
Motivation
We use a custom text area widget to always display the summary and similar minor changes. I would like to use the maxlength functionality there as well, which should be no problem as its simply derived from the 'text_textarea_with_summary' widget. But I can't because of the hardcoded list of widget IDs.
Change
Add a hook to add additional widget IDs.
Comment | File | Size | Author |
---|---|---|---|
#7 | 2835738-7-custom-widget-full.patch | 7.08 KB | ChristianAdamski |
#5 | 2835738-5-test-only-field-ui.patch | 5.48 KB | ChristianAdamski |
#4 | 2835738-4-custom-widget-support.patch | 6.43 KB | ChristianAdamski |
#3 | 2835738-3-custom-widget-support-test-only.patch | 4.83 KB | ChristianAdamski |
Comments
Comment #2
ChristianAdamski CreditAttribution: ChristianAdamski at Wolters Kluwer commentedComment #3
ChristianAdamski CreditAttribution: ChristianAdamski at Wolters Kluwer commentedAdded test
Should fail
Comment #4
ChristianAdamski CreditAttribution: ChristianAdamski at Wolters Kluwer commentedWhole patch:
- added "hook_maxlength_widget_settings()"
- added api.php file with that hook
- altered WidgetSettings.php to invoke said hook
and
- above test (which took way longer than the other stuff)
Comment #5
ChristianAdamski CreditAttribution: ChristianAdamski at Wolters Kluwer commentedInteresting, so if the maxlength/maxlength_js settings re there, no matter how, they are used, even if the widget is not registered in the WidgetSettings.
- updated test to actually interact with the field UI to set values for maxlength and check them being present in the widget settings summary afterwards
This should fail.
Comment #7
ChristianAdamski CreditAttribution: ChristianAdamski at Wolters Kluwer commentedAnd this should work
Comment #9
dawehnerI couldn't think of a better non crazy implementation. In case we find one, we can always go to maxlength 2.x or even later.
Thank you for the patch. I commited and pushed it to 8.x-1.x