I have a requirement to add some expanding panels in my formtastic forms, so when a user clicks the '+', a hidden panel shows itself and gives more information about the field.
This is a standard formtastic field:
<%= form.input :name %>
# will become...
<li class="string input required stringish" id="employee_name_input">
<label class=" 开发者_如何学Golabel" for="employee_name"> Name </label>
<input id="employee_name" maxlength="255" name="employee[name]" required="required" type="text" value="Joe Bloggs" class="">
</li>
I need to customize this, so adding a class to 'form.input' will create a new element:
<%= form.input :name, :input_html => {:class => "turn_on_toggler"} %>
# becomes (the 2nd line has been added)...
<li class="string input required stringish" id="employee_name_input">
<a class="toggler expand_collapse"></a>
<label class=" label" for="employee_name"> Name </label>
<input id="employee_name" maxlength="255" name="employee[name]" required="required" type="text" value="Joe Bloggs" class="">
</li>
I am not familiar with formtastic's code at all. How would one accomplish this?
精彩评论