form_for closes <form> tag

前端 未结 3 559
情书的邮戳
情书的邮戳 2020-12-11 16:36

I have a strange situation happening on a page where my

tags are being closed immediately, leaving the form\'s contents on their own and not useful
相关标签:
3条回答
  • 2020-12-11 16:56

    My way to fix it is to include the submit button right before the end and make the button not display.

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

    This puts the ending tag right where I need it.

    0 讨论(0)
  • 2020-12-11 17:15

    I had this problem and figured it out. For me, it was because I was rendering the form in an invalid place. Specifically, I had some content like this:

    <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) into the tag fixed the problem.

    0 讨论(0)
  • 2020-12-11 17:18

    What version of Rails are you using? Coz till 2.3.2 form_for didn't return back a value

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

    Note the "=" missing at the start!

    0 讨论(0)
提交回复
热议问题