开发者

Customize formtastic to add an <a> in some list elements

开发者 https://www.devze.com 2023-04-01 18:58 出处:网络
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.

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消