Fixed bug with radio button not being checked (#501)

* Fixed bug with radio button not being checked

Fixes: https://github.com/LaravelCollective/html/issues/496

Loose comparison needs to be done because Laravel model casting may be in affect and therfore 1 == true and 0 == false.

* typo
This commit is contained in:
Devin authored and Tom Shafer committed 2018-03-16 09:57:16 -07:00
1 parent 41cd9291a6
commit 5060a6641d
2 files changed
+32 -3

No files matched your search

+17 -3
View File
@@ -190,7 +190,7 @@ class FormBuilder
{
$this->model = $model;
}
/**
* Get the current model instance on the form builder.
*
@@ -871,7 +871,7 @@ class FormBuilder
return $this->getRadioCheckedState($name, $value, $checked);
default:
return $this->getValueAttribute($name) === $value;
return $this->compareValues($name, $value);
}
}
@@ -924,7 +924,21 @@ class FormBuilder
return $checked;
}
return $this->getValueAttribute($name) === $value;
return $this->compareValues($name, $value);
}
/**
* Determine if the provide value loosely compares to the value assigned to the field.
* Use loose comparison because Laravel model casting may be in affect and therefore
* 1 == true and 0 == false.
*
* @param string $name
* @param string $value
* @return bool
*/
protected function compareValues($name, $value)
{
return $this->getValueAttribute($name) == $value;
}
/**