Skip to content
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

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

Open
wants to merge 1 commit into
base: 6.x
Choose a base branch
from

Conversation

vedant-jayale
Copy link

What does this PR do?

Fixes incorrect handling of radio inputs with falsy values (0, false, empty string) by replacing !$request with is_null($request) in FormBuilder.php.

Fixes #650

Why is this needed?

  • Bug: Radio buttons with value="0" showed as unchecked despite being selected
  • Root Cause: !$request evaluated all falsy values (0/false/"") as "missing"
  • Solution: is_null() specifically detects only truly missing fields (null)

Changes Made

  • Replaced !$request with is_null($request) in getRadioCheckedState()
  • Maintains backward compatibility (no breaking changes)
  • Aligns with standard HTML form behavior

Test Case | Before | After
value="0" | ❌ | ✅
value="1" | ✅ | ✅
Field not submitted | ✅ | ✅
  |

Fixes #650

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getRadioCheckedState - use is_null instead of !
1 participant