0

I want to make a button that will allow me to create a new text_field for :phone_number in addition to the one I already have. For example if I want to submit two phone number instead of one in separate fields how would that be accomplished? In the code below I have begun to make a button_to but am not sure what actions to take in order to make a new field of entry. thanks.

<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>
Billy
  • 823
  • 3
  • 12
  • 28

1 Answers1

0

You can accomplish this using JavaScript. Get the id of the button and then add the new input to the page when clicked.

hudsond7
  • 666
  • 8
  • 25