【发布时间】:2019-08-26 08:37:05
【问题描述】:
我正在使用 rails form_tag 帮助器为我的页面创建一个特定的帮助器。这是我的代码:
def horta_form(form, args = {})
set_editable(form) unless args[:editable] == false
identifier, send_to, classes, style = form.identifier, form.send_to, form.classes, form.style
form_tag("/contact", method: "post") do
text_field_tag('name')
text_field_tag('email')
text_area_tag('message')
submit_tag('Send')
end
end
但在我看来,它只呈现最后一个标签,submit_tag。
<%= horta_form(@form) %>
返回
<form action="/contact" accept-charset="UTF-8" method="post">
<input name="utf8" type="hidden" value="✓">
<input type="hidden" name="authenticity_token" value="/WLo9GzhGdD7dBk3Eh8k4Q/+jQ0r+EGqgoOXBedyl/NW6g5gBQ/R4U4gFEtXmz1xJlISHAYykZRkmDHhQJm8uQ==">
<input type="submit" name="commit" value="Send" data-disable-with="Send">
</form>
我应该怎么做才能让horta_form 返回包含所有输入的表单,而不仅仅是最后一个?
【问题讨论】:
标签: html ruby-on-rails ruby forms