Im trying for some time to use simple_form to create the below example but + the label and fixing some styling. Anyone knows how to fix:
Is the result from below code:
.clear
= f.label "Gender"
= f.collection_radio_buttons(:gender, [['Male', 'icon_male'], ['Female', 'icon_female']],
:first, :last,
:item_wrapper_class => 'horizontal',
) do |gender|
= gender.label { image_tag("/assets/icons/16x16/#{gender.text}.png") + gender.radio_button }
.clear
.ruler
To remove the 2s and get the text label in there on the right use:
= f.label "Gender"
= f.collection_radio_buttons(:gender, [['Male', 'icon_male'], ['Female', 'icon_female']],
:first, :last,
:item_wrapper_class => 'horizontal',
) { |gender| gender.label { image_tag("/assets/icons/16x16/#{gender.text}.png") + gender.radio_button + gender.text } }
Removing the =
before the gender.label
will remove the 2s.
Rubytastic you have an extra comma in your answer. Here is the correct code that @23inhouse was suggesting. It works for me in
= simple_form_for @object_new do |f|
.clear
= f.label "Gender"
- f.collection_radio_buttons(:gender, [['Male', 'icon_male'], ['Female', 'icon_female']], :first, :last, :item_wrapper_class => 'horizontal') do |gender|
= gender.label { image_tag("rails.png") + gender.radio_button }
.clear
.ruler
Final working snippet:
= f.label "Gender"
- f.collection_radio_buttons(:gender, [['Male', 'icon_male'], ['Female', 'icon_female']], :first, :last, :item_wrapper_class => 'horizontal') do |gender|
= gender.label { image_tag("/assets/icons/16x16/#{gender.text}.png") + gender.radio_button }
.clear
.ruler
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With