0

In my app i have a form with 4 fields that records information about a friend. (see screenshot)

At the bottom i have a button that dynamically duplicates the form should the user want to enter another record.

They way i have it setup is sort of messy and will be extremely long should the user want to add lots of records.

Is there a cleaner way to do this? Maybe some sort of jquery table?

enter image description here

View code:

<div id="single_module">
<div class="pitch">
<h2>Step 3: Friends Birthdays</h2>
</div>
<form id="myForm">
<div id="input1" style="margin-bottom:4px;" class="clonedInput">
<%= simple_form_for @user, url: wizard_path do |f| %>

  <div class="inputs">
  <ul class="testss1">
  <%= f.simple_fields_for :friends do |friend_f| %>
    <li>
    <%= friend_f.input :name %>
    </li>
    <li>
    <%= friend_f.input :dob, :as => :date_picker, :label => 'Birthday', :input_html => { :class => 'special' } %>
    <li>
    <%= friend_f.input :gender, :collection => ['male','female'] %></li>
    </li><li>
    <%= friend_f.association :interests, :as => :select, :label => false %></li>


    <%end%>

    </div>
    <div>
    <input type="button" id="btnAdd" value="add another name" />
    <input type="button" id="btnDel" value="remove name" />
    </div>
    </form>
    <div class="actions">
    <%= f.button :submit, 'Next Step', :class => 'btn btn-primary',  %>
    <br></br>
    </div>
    <%end%>
4

1 回答 1

2

你每次保存的时候完成,再添加一个朋友点击吗?为什么不在临时隐藏字段中保存数据,然后清除表单中的所有数据并让用户添加另一条记录?

于 2012-05-25T20:32:14.253 回答