diff --git a/classes/Form.php b/classes/Form.php index f2445357..0988da6d 100644 --- a/classes/Form.php +++ b/classes/Form.php @@ -841,6 +841,9 @@ public function post() if ($field['type'] === 'checkbox' || $field['type'] === 'switch') { $data[$name] = isset($data[$name]) ? true : false; } + if ($field['type'] === 'checkboxes' && !isset($data[$name])) { + $data[$name] = []; + } $i++; } diff --git a/templates/forms/fields/checkboxes/checkboxes.html.twig b/templates/forms/fields/checkboxes/checkboxes.html.twig index ba9a6506..8f548598 100644 --- a/templates/forms/fields/checkboxes/checkboxes.html.twig +++ b/templates/forms/fields/checkboxes/checkboxes.html.twig @@ -2,7 +2,7 @@ {% set originalValue = value %} {% set value = (value is null ? field.default : value) %} -{% if field.use == 'keys' and field.default %} +{% if field.use == 'keys' and field.default and value is null %} {% set value = field.default|merge(value) %} {% endif %}