【发布时间】:2017-02-21 00:42:45
【问题描述】:
ActiveAdmin 表单:
我的问题:我无法获得包含多项选择文件的表单(
我试过了:
ActiveAdmin.register Foto do:
form :html => { :multipart => true } do |f|
f.inputs "Upload" do
f.input :foto, :as => :file
end
f.actions
end
end
这样不行,然后我做了一个简单的html页面,有两种形式:
<!DOCTYPE doctype html>
<html>
<head>
</head>
<body>
<!--**not** work multiple choice files-->
<form accept-charset="UTF-8" action="#" enctype="multipart/form-data" method="post">
<input id="image" name="image" type="file"/>
</form>
<!--**great** work multiple choice files-->
<form accept-charset="UTF-8" action="#" method="post">
<input id="image" name="image" type="file" multiple=""/>
</form>
</body>
</html>
问题:如何将一个属性添加到多个输入字段?
我试过了:
f.input :foto, :as => :file, :html => {:multiple => ""}
f.input :foto, :as => :file, :html => {:multiple => ""}
f.input :foto, :as => :file, :html => {"multiple" => "multiple"}
f.input :foto, :as => :file, :html => {:multiple => :multiple}
这不起作用
请帮帮我。
【问题讨论】:
-
不起作用是什么意思?抛出一些错误?没有选择多个文件?
-
试试这个
f.input :foto, as: :file, input_html: { multiple: true }。如果有效,我可以将其发布为答案。我没有测试过 -
不需要使用 ':html => { :multipart => true }' ,只需使用 'form do |f|' ,使用 'f.input :foto, :as => :file' 并检查您的模型照片是否保存为 foto 而不是 'photo' 因为您有拼写错误。
-
f.input :foto, as: :file, input_html: { multiple: true } - 有效,谢谢!您是从哪里听说 input_html 的?
-
我的模型是:class Foto { :multipart => true }' 不行!
标签: ruby-on-rails activeadmin formtastic