I'm trying to do this:
= f.input_field :time_of_day, label: false,
collection: [:all, :morning, :afternoon, :evening, :night],
checked: params[:events][:time_of_day],
as: :radio_buttons, item_wrapper_class: 'button secondary small'
But it generates:
<span class="radio button secondary small">
<label for="events_time_of_day_all">
<input label="false" item_wrapper_class="button secondary small" class="radio_buttons required" type="radio" value="all" name="events[time_of_day]" id="events_time_of_day_all"> All
</label>
</span>
So the label is present despite adding "label: false". Any ideas how to remove the label?
The label: false option is used to disable the outmost label when you use input, it is not used with input_field, thus being considered a simple html attribute as any other.
The generated label is there due to the radio button collection, each item gets it's own label. To disable that you need to use the block form, there should be examples on how to achieve that in the collection_radio_buttons helper. If you still need help with that, please use the mailing list or stack overflow, or if you still find there's a bug here, let me know and we can reopen. Thanks!
@carlosantoniodasilva
This is not true!
@builder.collection_check_boxes attribute_name,
options[:collection].first(1),
options[:value_method],
options[:label_method], item_wrapper_tag: false do |b|
b.check_box
end
Produces
"<label for=\"business_business_badge_ids_wi-fi\"><input type=\"checkbox\" value=\"wi-fi\" name=\"business[business_badge_ids][]\" id=\"business_business_badge_ids_wi-fi\" /></label><input type=\"hidden\" name=\"business[business_badge_ids][]\" value=\"\" />"
I really have no idea how to get rid of that label. Thanks.
another byebug session showed that i need to set :boolean_style to something, and that 'something' should not be :nested.
So boolean_style: false resolved that issue for me.
None of the earlier helped me. I could get rid of the label with setting it as empty string by label: '', setting it to false or nil didn't change anything.
I now don't have the label anymore but the first record of the checkbox list has misalignment issue- checkbox is on the right side of the container while its label is on the next line left side. All the rest of the checkboxes are aligned correctly. I don't have any custom setup here so I'm pretty sure it's some kind of form method internal issue.
Most helpful comment
another byebug session showed that i need to set :boolean_style to something, and that 'something' should not be :nested.
So boolean_style: false resolved that issue for me.