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, can you see the problem?
<%= 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 %>
Results in 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=>
, etc etc just seem to give errors too.
<%= f.submit, class: "btn btn-default btn-xs" %>
results in this error:
SyntaxError in TodoListsController#edit ...... _form.html.erb:23: syntax error,unexpected tLABEL, expecting '=' ...uffer.append=( f.submit, class: "btn btn-default btn-xs" );@... ... ^
Passing 'form-horizontal' into form_for
still produces an error;
<%= form_for(@todo_list, html => {:class => "form-horizontal"}) do |f| %>
....
....
<%= f.submit, class: "btn btn-default btn-xs" %>
SyntaxError in TodoListsController#edit ... _form.html.erb:23: syntax error, unexpected tLABEL, expecting '=' ...uffer.append=( f.submit, class: "btn btn-default btn-xs" );@... ... ^
Note that if i explicitly declare 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