Rails form_tag远程以另一种形式

时间:2016-12-07 18:04:45

标签: javascript ruby-on-rails ruby forms

我一直在关注此视频http://php.net/manual/en/mysqli.quickstart.dual-interface.php,我正试图以其他形式搜索记录,但不能正常工作,我该如何解决?我需要将搜索表单放入创建表单中以搜索要保存的记录。这是我的表格:

<%= form_for(@cliente, remote: true, html: {class: "form-horizontal cliente-validado"}) do |f| %> <!--ajax remote: true-->
  <div class="modal fade" id="mynewcliente" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title" id="myModalLabel">Agregar cliente</h4>
        </div>
        <div class="modal-body">

          <%= f.label :IdCli, "Clave:", class: "control-label col-md-2" %>
            <div class="col-md-7">
              <%= f.text_field :IdCli, class: "form-control cliente-idcli",autofocus: true, minlength: "1", required: "true"   %>
            </div>

<!--the search form-->
              <%= form_for("/busqueda_cp", method: 'get', remote: true, id:"cp_search" ) do |l| %>
              <p>
                <%= l.text_field :search, params[:search]%>
                <%= submit_tag "Search", :name => nil%>
              </p>
              <%end%>
                <div id="cp"><%= render 'cp' %></div>

          <div class="form-group">
            <%= f.label :Status,"Activo:", class: "control-label col-xs-3 col-sm-6 col-md-1 " %>
            <div class="col-md-1">
              <%= f.check_box :Status, checked: true %>
            </div>
          </div>
        </div>

        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal" id="mynewclienteclose">Close</button>
          <%= submit_tag "Create", class: "btn btn-primary", data: { disable_with: 'Creando' }%>
        </div>
      </div>
    </div>
  </div>
<%end%>
</div>

1 个答案:

答案 0 :(得分:2)

嵌套表单(表单内的表单)不受浏览器支持(不属于w3c标准),并且可能导致不可预测的行为。

您可以在此处详细了解: