ruby on rails 3 - simple_form radio button (need to add <span> tag inside of <label> -
what best way create following html using simple_form_for gem?
<label> <input name="form-field-radio" type="radio" /> **<span class="lbl"> radio option 2</span>** </label>
note default when create radio buttons using following statements, above not created. how can add tag in?
<%= f.input :state, :collection => project::states, :as => :radio_buttons %>
i had similar need (to embed <span>
within <label>
). isn't cleanest solution did work , think tweaking ability have input , span embedded within label. following modification results in:
<label>name: <span class="hint">this hint...</span> </label>
i added following initializer (using rails 4 , simple_form 3) override label_text method:
# initializers/simple_form_custom.rb module simpleform module components module labels def label_text if hint hint_text = %[<span class="hint">#{hint}</span>] else hint_text = "" end simpleform.label_text.call(raw_label_text, required_label_text, hint_text).strip.html_safe end end end end
then in initializers/simple_form.rb
have:
config.label_text = lambda { |label, required, hint| "#{label}: #{required} #{hint}" }
Comments
Post a Comment