Simple_form: radio_buttons + label:false not working

Created on 17 Feb 2020  路  4Comments  路  Source: heartcombo/simple_form

when using as: :radio_buttons, label is present event if label: falseis added.

Current behavior

= f.association :service, collection: Service.all, as: :radio_buttons, label: false
=> Label is still visible

Expected behavior

=> Label is removed

Needs more info

All 4 comments

Could you please provide us a sample application that reproduces the issue in isolation?

That would help us find the issue.

@yshmarov I know this is months old, but I think I had the same issue you did. SimpleForm renders vertical_collection inputs with a <legend> element instead of a label, even though it will use the label's text. If you replace your line:

f.association :service, collection: Service.all, as: :radio_buttons, label: false

with this:

f.association :service, collection: Service.all, as: :radio_buttons, label_text: false

I'm willing to bet it'll fix the problem you had.

I have the same issue, and the suggestion above half-fixes it. It empties the <legend> element, but does not remove it from the generated HTML. Whilst you could style the legend to have zero size or display: none, it would be nice for it not to be there in the first place when using label: false

Had the same problem.

@davelens' workaround makes the labels disappear, thanks.

@pacso's comment is true, the empty <legend> elements disrupt my layout ever so slightly, but it's better than the labels.

Was this page helpful?
0 / 5 - 0 ratings