Skip to content

Commit 65da8b2

Browse files
authored
[5.2] Add support ID with 0 for value CheckboxField.php (joomla#37174)
1 parent a8b105a commit 65da8b2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libraries/src/Form/Field/CheckboxField.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
137137
protected function getLayoutData()
138138
{
139139
$data = parent::getLayoutData();
140-
$data['value'] = $this->default ?: '1';
140+
// Allow any non-empty string, such as '0', to be used as the default value for a checkbox
141+
$data['value'] = $this->default !== null && $this->default !== '' ? $this->default : '1';
141142
$data['checked'] = $this->checked || $this->value;
142143

143144
return $data;

0 commit comments

Comments
 (0)