【发布时间】:2018-01-29 23:28:56
【问题描述】:
我是 Rails 表单的新手,并且有以下表单字段:
<%= f.label :name, class: "black-text" %>:
<%= f.text_field :name, class: "white task-card", :required => true %>
<%= f.label :foo, class: "black-text" %>:
<% options = [['Option A', 1], ['Option B', 2], ['Option C', 3], ['Option D', 4]] %>
<%= f.select :foo, options_for_select(options), {}, {:include_blank => true, :required => true, class: "white task-card"} %>
如果留空,文本输入字段将不会前进并正确提醒用户“请填写此字段”,但选择选项不会。如果选择字段保留其默认的空白值,页面将不会前进,因此它会以这种方式工作,但不会提醒用户为什么什么都没有发生。如何使浏览器的标准 HTML5“请不要填写此字段”警报适用于选择字段?
谢谢!
【问题讨论】:
-
从未找到答案?
标签: ruby-on-rails forms drop-down-menu