Search code examples
ruby-on-railsformstwitter-bootstraproleform-helpers

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| %>

Solution

  • You need to specify it as an html option:

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