我正在使用简单形式的 gem 来渲染我的表单。我正在尝试将输入字段类型设置为“数字”。此代码不起作用:
f.input :amount, input_html: { type: 'number' }
正确的设置方法是什么?
以下应该有效
f.input :amount, input_html: { type: 'number' }
更干净的方法是:
f.input :amount, as: :numeric
希望有帮助!
最简单的方法:
f.input :whatever, as: :numeric
尝试:
f.input :amount, as: :integer
我在执行此操作时遇到了不同的问题
<%= f.input :password,
as: :string,
required: false,
input_html: { autocomplete: "current-password" }%>
实际的形式只接受整数而不是字符串,因为它应该......我尝试使用 as: :string 但仍然不起作用...有什么想法吗?