Skip to content

fix(FormBuilder): correct radio checked state for falsy values (fixes #650) #828

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: 6.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -962,11 +962,13 @@ protected function getCheckboxCheckedState($name, $value, $checked)
protected function getRadioCheckedState($name, $value, $checked)
{
$request = $this->request($name);

if ($this->missingOldAndModel($name) && !$request) {

// Changed from !$request to is_null() to fix 0/false values issue
if ($this->missingOldAndModel($name) && is_null($request)) {
return $checked;
}


// Otherwise compare against existing values (old input > model > request)
return $this->compareValues($name, $value);
}

Expand Down