今天写一些 html 代码,如下
<div>
<%= form_for ProductPicture.new, url: create_product_picture_admin_box_path(product), method: :post, remote: true, html: {class: "picture_file_upload", id: "product_#{product.id}_new_product_picture"} do |f| %>
<%= f.file_field :picture, multiple: true, name: "product_picture[picture]", id: "product_#{product.id}_product_picture_picture" %>
<%= f.submit "ok", class: "btn btn-info" %>
<% end %>
</div>
然后在 html 生成的代码如下
<div>
<form class="picture_file_upload" id="product_103_new_product_picture" enctype="multipart/form-data" action="/admin/boxes/4db6265c/create_product_picture" accept-charset="UTF-8" data-remote="true" method="post"></form> <input name="utf8" type="hidden" value="✓">
<input multiple="multiple" name="product_picture[picture]" id="product_103_product_picture_picture" type="file">
<input type="submit" name="commit" value="ok" class="btn btn-info">
</div>
为什么生成的 input 会跑到 form 外面去了呢?