Rails: remove the label from a simple_form_for collection association

612 Views Asked by At

I am trying to remove the label that is auto included when we use '.association' of the simple_form_for. But, regardless of what I do, the title and its <hr> continue to be displayed.

I tried:

<%= f.association :attr_vals, collection: attr.attr_vals, 
    as: :check_boxes, wrapper: false, label: false %>

and

<%= f.association :attr_vals, collection: attr.attr_vals, 
    as: :check_boxes, wrapper: false, label: "" %>

But it keeps showing :/

What can I do to remove it?

2

There are 2 best solutions below

0
Rasna Shakya On

You can try this:

<%= f.association :attr_vals, collection: attr.attr_vals, 
    as: :check_boxes, wrapper: false, label_method: "" %>
0
aqwan On

label: false seems to work, for example handling an enum collection

    <%= form.association :functions,
                          collection: functions.map { |f| [Function.functions.key(f)&.humanize, f] }, 
                          as: :check_boxes, 
                          label: false %>