supersize
supersize

Reputation: 14833

Rails simple form how to wrap HTML around label and input element

I started playing around with Rails and found a very good gem called Simple Form. When simple form generates the input elements I tried to fiddle out how to wrap another HTML element around the label and input field.

= f.input :existingname, placeholder: 'Your name is?'

and the output is:

<div>
  <label></label>
  <input>
</div>

but I want to have:

<div>
  <span><label></label></span> 
  <span><input></span>
</div>

Any help with this?

Upvotes: 0

Views: 1137

Answers (1)

Zara Kay
Zara Kay

Reputation: 164

From what I gather from the site, you need to add a custom wrapper edit some settings in config/initalizers/simple_form.rb

That file also has several pre-existing settings you can edit to add wrappers.

One line that stood out was:

config.item_wrapper_tag = :span

I haven't had a chance to play with it, but there is plenty of documentation in the file. If they don't work out, you can create a custom wrapper, documentation for that can be found on the wiki at the simple_form github page here

Upvotes: 1

Related Questions