通过模态编辑嵌套表单

时间:2014-06-20 08:29:23

标签: javascript ruby-on-rails ruby nested-forms

我有一个嵌套模型,我已经完成了保存和检索数据。但是,我仍然坚持编辑这些数据。有人可以帮助我。

这是我的表格:

  <% @case.case_parties.each_with_index do |party, index| %>
           <% set_index = index + 1 %>
           <% @party_ids << party.id %>
           <tr>
            <% if party.client_party_name.present? %>
             <td><%= set_index %></td>
             <td><%= party.client_party_name %></td>
             <td>

             <%= link_to '#', :class => "btn btn-warning", 'data-target' => "#client_party_modal_#{party.id}", 'data-toggle' => 'modal' do %>
                <i class="icon-pencil"></i>
              <% end %>
             </td>
            <% end %>
           </tr>
          <% end %>

这是我的模态:

        <div class="modal" id='<%= "client_party_modal_#{party.id}" %>' tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title" id="myModalLabel">Modal title</h4>
          </div>
          <div class="modal-body">
               <div class="box box-bordered blue-border box-nomargin">
                  <div class="box-header box-header-small blue-background">
                    <div class="title">Party #<span class="party_number"></span></div>
                    <div class="actions">
                      <a class="btn box-remove btn-xs btn-link" href="#"><i class="icon-remove"></i>
                      </a>
                      <a class="btn box-collapse btn-xs btn-link" href="#"><i></i>
                      </a>
                    </div>
                  </div>
                <div class="box-content">

                  <div class="container">
                    <div class='form-group'>
                      <%= builder.label :client_party_name, 'Name of Party' %>
                      <%= f.text_field :client_party_name, class: 'form-control' %>
                    </div>

                    <div class='form-group'>
                      <%= builder.label :client_party_is, "Party is" %>
                      <%= builder.collection_select :client_party_is, Litigation::CLIENT_IS_ADVERSARY_IS, :to_s, :titleize, { prompt: true }, { class: 'form-control select2 client_party_is' } %>
                    </div>

                    <div class='form-group'>
                      <%= builder.label :client_party_address, "Party Address" %>
                      <%= builder.text_area :client_party_address, class: 'form-control' %>
                    </div>

                    <div class='form-group'>
                      <%= builder.label :client_party_lawyer, "Party's Lawyer" %>
                      <%= builder.text_field :client_party_lawyer, class: 'form-control' %>
                    </div>

                    <div class='form-group'>
                      <%= builder.label :client_party_lawyer_address, "Lawyer's Address" %>
                      <%= builder.text_area :client_party_lawyer_address, class: 'form-control' %>
                    </div>
                  </div>

                </div>
              </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary">Save changes</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

我做得对吗?

0 个答案:

没有答案