-
Notifications
You must be signed in to change notification settings - Fork 505
Validate user to keep atleast one dynamic field. #197
Comments
Could you please explain your issue with some more details? Providing an example application reproducing your issue would be very helpful. |
I have got two problems:
newoffer.html.erb<%= f.fields_for :couponranges do |builder| %>
<%= link_to_add_fields "Add another range", f, :couponranges %>
offers_controllerdef newoffer application_helpermodule ApplicationHelper def link_to_add_fields(name, f, association) end application.jsfunction remove_fields(link) { function add_fields(link, association, content) { _couponrange_fields.html.erb
<%= f.label :from, "Coupon value from " %>
<%= f.text_field :from, :size => "6" %>
<%= f.label :to, "Coupon value to "%>
<%= f.text_field :to, :size => "6" %>
<%= f.label :from, " Discount offered "%>
<%= f.text_field :discount, :size => "6"%>
<%= link_to_remove_fields "Remove", f %>
|
It doesn't seem to be a nested_form issue as you're using your own helpers and javascript. I'd recommend using StackOverflow for such questions. Thanks! |
I ma trying to put the validation on dynamic field such that the user can't delete all the dynamic fields from the form. I have tried number of things, but still not getting it done. Is there any solution for that?
The text was updated successfully, but these errors were encountered: