--- id: type: 'string' name: type: 'string' default: '' required: type: 'bool' default: false attributes: type: 'string' default: '' class: type: 'string' default: 'form-select' items: type: 'array' --- {% assign base_id = id | append: '_' %} {% assign name = name | default: id | append: '[]' %} {% assign attributes = attributes | append: ' ' | append: 'data-required-checkbox-target="checkbox" data-action="required-checkbox#change"' %} {% comment %} Array parameters do not play well with the check_box helper. According to the HTML specification unchecked checkboxes submit no value. However it is often convenient for a checkbox to always submit a value. The check_box helper fakes this by creating an auxiliary hidden input with the same name. If the checkbox is unchecked only the hidden input is submitted and if it is checked then both are submitted but the value submitted by the checkbox takes precedence. Source: https://guides.rubyonrails.org/v6.1/form_helpers.html#combining-them {% endcomment %} {% render 'forms/hidden.html', name:, id:, value: '' %}