0
votes

I have simple_form for forms in my app and Ive been using horizontal wrapper as I want the label and input to be on the same level. ie:

<%= simple_form_for @task, html: {class: 'form-horizontal'}, wrapper: :horizontal_input_group do |f| %>

<%= simple_form_for @user, html: {class: 'form-horizontal'}, wrapper: :horizontal_input_group do |f| %>

NOW, I HAVE ENCOUNTERED THIS ERROR IN THIS SIMPLE FORM FOR:

<%= simple_form_for ([@task, Response.new]), html: {class: 'form-horizontal'}, wrapper: :horizontal_input_group  do |f| %>

The error is:

html.erb:37: syntax error, unexpected keyword_do, expecting keyword_end
er: :horizontal_input_group  do |f| @output_buffer.safe_appe...

The expecting key word end does not make sense cause i have <% end %> at the end of this simple_form. If I remove this line:

, wrapper: :horizontal_input_group

...it will work.... but I need it as I want my label and input to be on the same line. It is just strange that it works on my other simple_form for. Only in this form is not working when I add this code:

, html: {class: 'form-horizontal'}, wrapper: :horizontal_input_group

Can someone please help me/explain it to me why is this happening.

1
I think the parentheses are confusing the parser and limiting what arguments are being passed to the method... try instead <%= simple_form_for(([@task, Response.new]), html: {class: 'form-horizontal'}, wrapper: :horizontal_input_group) do |f| %> and let me know if that works.SteveTurczyn
i see. this works like a charm. thank you for the explanationjumbo_siopao
Great. If you don't mind, I'll post it as an answer so you can accept it. Cheers, SteveSteveTurczyn

1 Answers

0
votes

The parentheses are confusing the parser and limiting what arguments are being passed to the method. Try instead:

<%= simple_form_for(([@task, Response.new]), html: {class: 'form-horizontal'}, wrapper: :horizontal_input_group) do |f| %>

This will ensure all arguments... the array, and the options hash with :html and :wrapper keys... are passed to the simple_form_for method.