Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c7dd000

Browse files
committed
Fix form builder with model binding.
1 parent 8e218bc commit c7dd000

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/Illuminate/Html/FormBuilder.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ protected function getCheckboxCheckedState($name, $checked)
618618
{
619619
if ( ! $this->oldInputIsEmpty() and is_null($this->old($name))) return false;
620620

621-
if (is_null($this->old($name))) return $checked;
621+
if ($this->missingOldAndModel($name)) return $checked;
622622

623623
return (bool) $this->getValueAttribute($name);
624624
}
@@ -633,11 +633,22 @@ protected function getCheckboxCheckedState($name, $checked)
633633
*/
634634
protected function getRadioCheckedState($name, $value, $checked)
635635
{
636-
if (is_null($this->old($name))) return $checked;
636+
if ($this->missingOldAndModel($name)) return $checked;
637637

638638
return $this->getValueAttribute($name) == $value;
639639
}
640640

641+
/**
642+
* Determine if old input or model input exists for a key.
643+
*
644+
* @param string $name
645+
* @return bool
646+
*/
647+
protected function missingOldAndModel($name)
648+
{
649+
return (is_null($this->old($name)) and is_null($this->getModelValueAttribute($name)));
650+
}
651+
641652
/**
642653
* Create a HTML reset input element.
643654
*

0 commit comments

Comments
 (0)