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.
I have a bug in my configuration where I'm using a the widget "Select (or other) list" on a non-required "float" field.
When an editor is leaving the field blank (using "- None -") it triggered the validation error: FieldName field must be a valid integer or decimal.
I tracked down the issue to the function select_or_other_field_widget_validate()
: where the following if condition is TRUE, but IMO it shouldn't.
if ($value !== "") {
}
Im my case the $value contains no data BUT it is not a string!
I'm suggesting to apply the following condition instead:
if ($value != "") {
}
(PS: I'm running PHP 7.0.x, maybe it does matter...)
Comment | File | Size | Author |
---|---|---|---|
#4 | field_validation_for_non_required-2907915-4.patch | 548 bytes | gabriel.achille |
| |||
#2 | field_validation_for_non_required-2907915-1.patch | 546 bytes | gabriel.achille |
|
Comments
Comment #2
gabriel.achille CreditAttribution: gabriel.achille as a volunteer commentedThe proposed patch.
Comment #3
legolasboI think !empty() would be better because it doesn't rely on type juggling and conveys intent better.
Comment #4
gabriel.achille CreditAttribution: gabriel.achille as a volunteer commentedagreed.
There is an updated patch.
Comment #5
daften CreditAttribution: daften at Dropsolid commentedClosing as outdated because no activity in a long time and Drupal 7 goes EOL soon. Feel free to re-open if needed.