I am trying to style form elements within this rails form_for but continually run into syntax error, nothing i try seems to be working:
_form.html.erb:
<%= form_for(@todo_list) do |f| %>
<div class="form-group">
<%= f.label :title %><br>
<%= f.text_field :title %>
</div>
<div class="form-group">
<%= f.label :description %><br>
<%= f.text_area :description %>
</div>
<div>
<%= f.submit, html: {class: "btn btn-default btn-xs"} %>
</div>
<% end %>
This just gives this error:
_form.html.erb:23: syntax error, unexpected tLABEL, expecting '=' ...buffer.append=( f.submit, html: {class: "btn btn-default btn... ...
All sorts of variations of class=
, class:
, html=>
, passing in html => {:class => "form-horizontal"}
, etc etc, all just seem to give the same syntax error.
The only exception is when I explicitly apply a label to the submit action, e.g.;
<%= f.submit 'Save', class: "btn btn-default btn-xs" %>
Then the class gets added successfully and my bootstrap styling works. However this neither locates the primary problem nor solves it as then I can't use rails' form_for dynamic naming of the submit action.
Classes I apply to divs seem to work fine, bootstrap is loaded fine. Can anyone help? Thanks
<%= f.submit class: "btn btn-primary btn-xs" %>
not<%= f.submit, class: "btn btn-primary btn-xs" %>
– jbk