문제

Twitter Bootstrap has this role attribute for forms:

<form role="form">

How can I include the role attribute in Rails form helpers? I tried this, but it doesn't work:

<%= form_for @user, class: "form-horizontal", role: "form" do |f| %>
도움이 되었습니까?

해결책

You need to specify it as an html option:

<%= form_for @user, html: {class: "form-horizontal", role: "form"} do |f| %>

다른 팁

form_for and form_tag have to be used differently:

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| %>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top