Open james-em opened 2 years ago
I came across this issue while trying to set vertical radio button and checkboxes labels to false. When you add label: false
, the label does not get removed. You must do legend_tag: false
. This isn't included in the readme.
I noticed in the simple forms bootstrap initializers, the vertical collections create the label using a legend_tag
wrapper.
config.wrappers :vertical_collection, item_wrapper_class: 'form-check', item_label_class: 'form-check-label', tag: 'fieldset', class: 'mb-3' do |b|
b.use :html5
b.optional :readonly
b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
ba.use :label_text
end
b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
b.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
b.use :hint, wrap_with: { class: 'form-text' }
end
The vertical_collection and vertical_collection_inline templates create labels differently. I would propose updating the file to make them follow the same format.
# vertical input for radio buttons and check boxes
config.wrappers :vertical_collection, item_wrapper_class: 'form-check', item_label_class: 'form-check-label', tag: 'fieldset', class: 'mb-3' do |b|
b.use :html5
b.optional :readonly
b.use :label, class: 'col-form-label pt-0' <----- Update to this
b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
b.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
b.use :hint, wrap_with: { class: 'form-text' }
end
# vertical input for inline radio buttons and check boxes
config.wrappers :vertical_collection_inline, item_wrapper_class: 'form-check form-check-inline', item_label_class: 'form-check-label', tag: 'fieldset', class: 'mb-3' do |b|
b.use :html5
b.optional :readonly
b.use :label, class: 'col-form-label pt-0' <----- Update to this
b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
b.use :full_error, wrap_with: { class: 'invalid-feedback d-block' }
b.use :hint, wrap_with: { class: 'form-text' }
end
This means you would update your format to use these.
# Old Syntax
f.input :field, as: :radio_buttons, legend_tag: :false
# Now Syntax
f.input :field, as: :radio_buttons, label: :false
Environment
Current behavior
Expected behavior
To never show the label when the value is false.