Twitter Bootstrap具有表单的此角色属性:
<form role="form">
如何在Rails表单助手中包含角色属性?我试过这个,但它不起作用:
<%= form_for @user, class: "form-horizontal", role: "form" do |f| %>
答案 0 :(得分:17)
您需要将其指定为html选项:
<%= form_for @user, html: {class: "form-horizontal", role: "form"} do |f| %>
答案 1 :(得分:0)
form_for
和form_tag
必须采用不同的方式:
<强>的form_for:强>
<%= form_for @user, html: { class: "form-horizontal", role: "form" } do |f| %>
<强>的form_tag:强>
<%= form_tag some_path, class: "form-horizontal", role: "form" do |f| %>