0

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.

4

1 回答 1

0

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.

于 2015-04-05T13:52:56.857 回答