- Issue created by @coaston
- ๐ฎ๐ณIndia mohd sahzad
Mohd Sahzad โ made their first commit to this issueโs fork.
Hi,
I identified the issue and can provide a manual workaround until a patch can be made.
Problem is: When creating a new custom field, a new "Text (plain)" item is created by default with a 255 maxlength (Custom field items section of the page) + a new row is added in the bottom table for the item field settings (including maxlength). If you unfold the "Settings" tab of your field item row, you can see the maxlength parameter.
Now, when you update the maxlength value from the "Custom field items" section (e.g. 150 characters), it does not update the maxlength value in the table row "Settings" tab (although it should) which remains at 255 characters. Hence, when you try to save the form or add a new item, the form does not validate because the values do not match (see attached screenshot for example).Manual workaround is to edit both maxlength fields to get rid of the validation error.
- Status changed to Needs work
8 months ago 9:06am 22 April 2024 - ๐บ๐ธUnited States apmsooner
Thanks for the report. I am able to reproduce and will work on a solution for this.
I had a look at the code for further investigation and ajax works fine. Problem is $element['settings']['maxlength']['#default_value'] (this value is correctly updated) being overriden by $form_state->input value in TextWidget::widgetSettingsForm().
Maybe adding a condition to reset the input to the default value if it is out of range would fix the issue.
- ๐บ๐ธUnited States apmsooner
I'm thinking I'll just make maxlength in the widget settings required and set the #value property as the same as the #default_value. The reason being is that the widget settings may have value of 255 but the column settings may have changed and have e.g. 100. The maxlength should basically always be set to no more than what the storage allows. I realize i also need to expose the storage max_length for uri and telephone as the type can change from string to uri for example and the max_length storage settings just get inherited without ability to override. I'll have a patch up shortly that can be tested for all this.
- Status changed to Needs review
8 months ago 5:54pm 22 April 2024 - ๐บ๐ธUnited States apmsooner
Please try the patch and let me know if this fixes the issue. FYI, the uri and telephone field types now have max_length setting exposed in storage settings to prevent further issues in case the existing field type changes.
- ๐ธ๐ฐSlovakia coaston
Thank You @apmsooner
Patch #10 works for me and I am able to change and save the field. - ๐บ๐ธUnited States apmsooner
Thanks, I will revise this and modify some stuff for uri and telephone fields to get tests to pass. The storage settings on those should actually not be changed so just need to modify some widget settings defaults.
-
apmsooner โ
committed 5970431b on 3.0.x
Issue #3442408 by apmsooner, misterdidi, coaston: Max length storage/...
-
apmsooner โ
committed 5970431b on 3.0.x
- Status changed to Fixed
8 months ago 9:06pm 25 April 2024 - Status changed to Fixed
8 months ago 3:42pm 29 April 2024