feat: use normalized checkbox values in field handlers
This commit is contained in:
1 parent
6abfa122e4
commit
40c0042158
6 files changed
+69
-4
No files matched your search
@@ -153,6 +153,21 @@ abstract class AbstractParticipantFieldHandler implements ParticipantFieldHandle
|
||||
return is_numeric($value) ? (int) $value : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a checkbox/form toggle value to a boolean.
|
||||
*
|
||||
* Form checkboxes may submit true, false, 1, 0, '1', '0', or be absent.
|
||||
* This method treats only true, 1, and '1' as checked; everything else as unchecked.
|
||||
*
|
||||
* @param mixed $value The raw value from form submission
|
||||
*
|
||||
* @return bool True if the checkbox is considered checked, false otherwise
|
||||
*/
|
||||
protected function normalizeCheckboxValue(mixed $value): bool
|
||||
{
|
||||
return true === $value || 1 === $value || '1' === $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns field state modifications that should be applied after processing.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user