- Issue created by @gorkagr
- ๐ณ๐ฟNew Zealand quietone
In Drupal core changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies โ . Also mentioned on the version โ section of the list of issue fields documentation. Thanks.
- First commit to issue fork.
- Merge request !12623Issue #3534125: Unable to save list (integer) field if 0 is used as value and field has data โ (Open) created by annmarysruthy
- ๐ง๐ชBelgium gorkagr
I think changing to 'readonly' could do the trick, but users will be confused why the field cannot be edited (is does not have the 'disabled' style in the end)
I was taking a look at what causes the field to be validated, is within the 'FormValidator.php' class in \Drupal\Core\Form\ namespace
if we see line 261$is_empty_value = ($elements['#value'] === 0);
and when the field is disabled, #value contains 0 (int) while is not disabled, #value contains '0' (string)
So maybe we need to check also within that function that the field is not disabled (aka, there is no '#attributes') when the element is required within that same function...
Maybe$is_empty_value = ($elements['#value'] === 0 && !isset($elements['#attributes']['disabled']));
But i am not core expert...
- First commit to issue fork.
- ๐ฎ๐ณIndia libbna New Delhi, India
I agree with @gorkagr that using
readonly
does not visually indicate that the value field is non-editable, which can be confusing to users. Therefore, I updated the code as suggested in comment #5.With this change, the value field is correctly disabled, and I am able to update the label or add a new item without encountering validation errors. I have attached screenshots demonstrating the behavior with both the readonly and disabled attributes for comparison.
- ๐ฎ๐ณIndia abhijith s
abhijith s โ made their first commit to this issueโs fork.