I have adapted the
ace wrap bootstrap template to my rails project and need to generate this markup when creating radio buttons:
<div class="form-group radio_buttons optional loan_ref_credit_type">
<label class="radio_buttons optional col-xs-12
col-sm-3 control-label">
Ref credit type
</label>
<div class="col-sm-9">
<label class="radio">
<input class="radio_buttons optional ace" id="loan_ref_credit_type_id_1" name="loan[ref_credit_type_id]" value="1" type="radio">
<label class="collection_radio_buttons lbl no-padding-left" for="loan_ref_credit_type_id_1">
Secured
</label>
</label>
<label class="radio">
<input class="radio_buttons optional ace" id="loan_ref_credit_type_id_2" name="loan[ref_credit_type_id]" value="2" type="radio">
<label class="collection_radio_buttons lbl no-padding-left" for="loan_ref_credit_type_id_2">
Unsecured
</label>
</label>
</div>
</div>
This is my simple_form call:
= f.association :ref_credit_type,
as: :radio_buttons,
label_method: :description,
label_html: { class: 'col-xs-12' },
input_html: { class: 'ace' }
By setting
config.boolean_style = :inline
in simple_form.rb, I get really close. It generates the internal radio labels like this:
<label class="collection_radio_buttons" for="loan_ref_credit_type_id_1">
Secured
</label>
If there is a way to add the css classes I need to the internal radio data label, right next to "collection_radio_buttons" (the ace template specific class is "lbl" and I add "no-padding-left" to adjust button placement and also a non-breaking space for separation of text from the radio button circle inside the label block) I'd be good to go.
Is there way to add classes to the internal radio html label blocks?
Maybe a better way is a custom input and I tried that without success but I don't want to confuse the issue with that attempt so I'll try this question first.
Help greatly appreciated - Thank you.