form_for关闭< form>标签 [英] form_for closes <form> tag
问题描述
我在一个页面上发生了一个奇怪的情况,我的< form>
标签被立即关闭,留下了表单的内容并且没有用处。
以下是基本的ERB:
<%= form_for(@review )do | f | %GT;
<%=渲染'apply / review_form',:locals => {:f => f}%>
<%= f.text_field:笔记%>
<%end%>
看起来很简单吧?我已经尝试了部分的自己; text_field
本身;使用 form_tag
的不同版本,但没有任何效果。
HTML看起来像这样:
< div id =reviewContainer>
< / form>
< div style =margin:0; padding:0; display:inline>
< input name =utf8type =hiddenvalue =✓>
< input name =authenticity_tokentype =hiddenvalue =dJSuLMfhBSVKAM3Buwe1NjtBedSLQl062 / + oliGbBfE =>
< / div>
< input id =review_notesname =review [notes]size =30type =text>
< div class =clear>< / div>
< / div>
有什么想法?这似乎很简单,我不明白为什么它不会工作!
可能有帮助的信息
这个表单不是页面上唯一的表单,它被包含在一个JQuery Tools Scrollable中。
我有这个问题,并找出它。对我而言,这是因为我在一个无效的地方渲染了表格。具体来说,我有这样的内容:
< table>
< tr>
< td>
我可能要编辑
的东西< / td>
< div style =display:none>
<%= form_for thing_i_might_want_to_edit%>
...
<%end%>>
< / div>
< / tr>
< / table>
将隐藏的div(及其内部的表单)移入标记可以解决问题。
I have a strange situation happening on a page where my <form>
tags are being closed immediately, leaving the form's contents on their own and not useful.
Here's the basic ERB:
<%= form_for(@review) do |f| %>
<%= render 'apply/review_form', :locals => {:f => f} %>
<%= f.text_field :notes %>
<% end %>
Seems simple, right? I have tried the partial on its own; the text_field
on its own; a different version using form_tag
, but nothing works.
The 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 wouldn't be working!
Possibly helpful information
This form is not the only form on the page, and it is enclosed in a JQuery Tools Scrollable.
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.
这篇关于form_for关闭< form>标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!