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...)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gabriel.achille created an issue. See original summary.

gabriel.achille’s picture

Assigned: gabriel.achille » Unassigned
Status: Active » Needs review
FileSize
546 bytes

The proposed patch.

legolasbo’s picture

Status: Needs review » Needs work

I think !empty() would be better because it doesn't rely on type juggling and conveys intent better.

gabriel.achille’s picture

Status: Needs work » Needs review
FileSize
548 bytes

agreed.
There is an updated patch.

daften’s picture

Status: Needs review » Closed (outdated)

Closing as outdated because no activity in a long time and Drupal 7 goes EOL soon. Feel free to re-open if needed.