Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

include bootstrap role attribute in rails form helper

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| %>
like image 831
crispychicken Avatar asked Oct 27 '13 18:10

crispychicken


2 Answers

You need to specify it as an html option:

<%= form_for @user, html: {class: "form-horizontal", role: "form"} do |f| %>
like image 152
Peter Brown Avatar answered Sep 29 '22 20:09

Peter Brown


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| %>
like image 28
crispychicken Avatar answered Sep 29 '22 20:09

crispychicken