Possibility of boolean value for selected option in select field (#487)
* Validation in select field for boolean value of selected option * Adjusts * Update FormBuilder.php Adjustments * Test and adjusment on PHPDoc
This commit is contained in:
1 parent
360cb180f7
commit
050af9862b
2 files changed
+10
-2
No files matched your search
+4
-2
@@ -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
|
||||
@@ -787,7 +787,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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user