我想创建一个按钮,允许我创建一个新的text_field:phone_number和我已经拥有的那个。例如,如果我想在单独的字段中提交两个电话号码而不是一个,那将如何实现?在下面的代码中,我已经开始制作一个button_to,但我不确定要采取什么行动来创建一个新的进入领域。谢谢。
<div>
<%= form_for @reminder do |f|%>
<%= f.label "Your Reminder"%>
<%= f.text_area :text %>
<!-- button here to make new text_field to input in an extra phone number -->
<%=button_to "add another number", %>
<%= f.label "Phone Number" %>
<%= f.text_field :phone_number %>
<%= f.label "When to be sent" %>
<%= f.text_field :time%>
<%= f.label "Picture URL" %>
<%= f.text_field :picture %>
<%= f.label "Favorite?" %>
<%= f.check_box :favorite %>
<%= f.submit %>
<% end %>
</div>
答案 0 :(得分:0)
您可以使用JavaScript完成此操作。获取按钮的ID,然后在单击时将新输入添加到页面。