[5.5] Validation in select field for boolean value of selected option (#490)

* [5.5] Validation in select field for boolean value of selected option

* Adjustment
This commit is contained in:
Anderson Friaça authored and Tom Shafer committed 2018-02-12 06:19:55 -08:00
1 parent 215f20b8c2
commit b79edc7acf
2 files changed
+10 -2

No files matched your search

+4 -2
View File
@@ -572,7 +572,7 @@ class FormBuilder
*
* @param string $name
* @param array $list
* @param string $selected
* @param string|bool $selected
* @param array $selectAttributes
* @param array $optionsAttributes
* @param array $optgroupsAttributes
@@ -784,7 +784,9 @@ class FormBuilder
} elseif ($selected instanceof Collection) {
return $selected->contains($value) ? 'selected' : null;
}
if (is_int($value) && is_bool($selected)) {
return (bool)$value === $selected;
}
return ((string) $value === (string) $selected) ? 'selected' : null;
}