Form_for closes the <form> tag

I have a strange situation happening on a page where my <form> tags close immediately, leaving the contents of the form on their own and not useful.

Here's the main ERB:

 <%= form_for(@review) do |f| %> <%= render 'apply/review_form', :locals => {:f => f} %> <%= f.text_field :notes %> <% end %> 

Seems simple, right? I tried partial on my own; text_field itself; another version using form_tag , but nothing works.

HTML looks like this:

 <div id="reviewContainer"> <form accept-charset="UTF-8" action="/reviews" class="new_review" id="new_review" method="post"> </form> <div style="margin:0;padding:0;display:inline"> <input name="utf8" type="hidden" value="βœ“"> <input name="authenticity_token" type="hidden" value="dJSuLMfhBSVKAM3Buwe1NjtBedSLQl062/+oliGbBfE="> </div> <input id="review_notes" name="review[notes]" size="30" type="text"> <div class="clear"></div> </div> 

Any ideas? It seems so simple, I can’t understand why it won’t work!


Perhaps useful information

This form is not the only form on the page, and it is enclosed in JQuery Tools Scrollable.

+8
html ruby-on-rails ruby-on-rails-3 forms
source share
3 answers

I had this problem and figured it out. For me it was because I was making the mold in an unacceptable place. In particular, I had some content:

 <table> <tr> <td> Stuff I might want to edit </td> <div style="display: none"> <%= form_for thing_i_might_want_to_edit %> ... <% end %> </div> </tr> </table> 

Moving the hidden div (and the form inside it) to the tag fixes the problem.

+3
source share

What version of Rails are you using? Coz prior to version 2.3.2 form_for did not return the value back

 <% form_for(@review) do |f| %> 

Note that the "=" is missing at the beginning!

0
source share

My way to fix this is to turn on the submit button to the end and make the button not displayed.

  <%= submit_tag('',style: 'width:0;height:0;display:none;') %> <% end %> 

This puts the end tag where I need it.

0
source share

All Articles