Fix bug with check state in form builder.
This commit is contained in:
1 parent
6120b9c5da
commit
52bc6cd4fb
1 file changed
+17
-2
+17
-2
@@ -483,13 +483,28 @@ class FormBuilder {
|
|||||||
*/
|
*/
|
||||||
protected function checkable($type, $name, $value, $checked, $options)
|
protected function checkable($type, $name, $value, $checked, $options)
|
||||||
{
|
{
|
||||||
if (is_null($checked)) $checked = (bool) $this->getValueAttribute($name, null);
|
if (is_null($checked)) $checked = $this->getCheckedState($type, $name, $value);
|
||||||
|
|
||||||
if ($checked) $options['checked'] = 'checked';
|
if ($checked) $options['checked'] = 'checked';
|
||||||
|
|
||||||
return $this->input($type, $name, $value, $options);
|
return $this->input($type, $name, $value, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the check state for a checkable input.
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @param string $name
|
||||||
|
* @param mixed $value
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function getCheckedState($type, $name, $value)
|
||||||
|
{
|
||||||
|
if ($type == 'checkbox') return (bool) $this->getValueAttribute($name);
|
||||||
|
|
||||||
|
return $this->getValueAttribute($name) == $value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a submit button element.
|
* Create a submit button element.
|
||||||
*
|
*
|
||||||
@@ -662,7 +677,7 @@ class FormBuilder {
|
|||||||
* @param string $value
|
* @param string $value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getValueAttribute($name, $value)
|
protected function getValueAttribute($name, $value = null)
|
||||||
{
|
{
|
||||||
if ( ! is_null($value)) return $value;
|
if ( ! is_null($value)) return $value;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user