如何在一个 Rails 4 输入字段上有 2 种类型?
How to have 2 types on one Rails 4 input field?
在我们的 Rails 4.2 应用程序中,有一个 hidden_file
字段,我们希望它既是 :hidden 又是 :file (type):
<%= f.input :hidden_file, as: :file & :hidden %>
我们尝试过:
<%= f.input :hidden_file, as: [:file, :hidden] %>
它returns错误:
undefined method `to_sym' for [:file, :hidden]:Array
以下仅将 :hidden 作为选项并省略 :file :
<%= f.input :hidden_file, as: :file, as: :hidden %>
as:
(类型)有 2 个选项的正确方法是什么?
您必须将文件输入字段放在隐藏的 div 中。
<div style="overflow: hidden;width:83px;">
<input name="userfile" id="userfile" type="file"/>
</div>
据我所知,您不能在 html 字段上放置两种类型,至少这是我对 html spec
的理解
在我们的 Rails 4.2 应用程序中,有一个 hidden_file
字段,我们希望它既是 :hidden 又是 :file (type):
<%= f.input :hidden_file, as: :file & :hidden %>
我们尝试过:
<%= f.input :hidden_file, as: [:file, :hidden] %>
它returns错误:
undefined method `to_sym' for [:file, :hidden]:Array
以下仅将 :hidden 作为选项并省略 :file :
<%= f.input :hidden_file, as: :file, as: :hidden %>
as:
(类型)有 2 个选项的正确方法是什么?
您必须将文件输入字段放在隐藏的 div 中。
<div style="overflow: hidden;width:83px;">
<input name="userfile" id="userfile" type="file"/>
</div>
据我所知,您不能在 html 字段上放置两种类型,至少这是我对 html spec
的理解