Eladio B. Caritos II
2005-Oct-14 01:55 UTC
Adding extra field in form using ajax causes extra field to be overwritten, any way around that.
I''m having trouble when I try to add another field in the form using ajax. I''m trying to add another line_item object into the invoice and i''m using the link_to_remote function to implement this. When I do that though and submit to the form, the line_item entries all have the same field name so they get overwritten. I''m not sure how to get around that. Here is my _form.rhtml: <%= error_messages_for ''invoice'' %> <!--[form:invoice]--> <p><label for="invoice_invoice_date">Invoice date</label><br/> <%= datetime_select ''invoice'', ''invoice_date'' %></p> <table border=1> <tr> <td>Description</td><td>Price</td> </tr> </table> <table border=1><tr><td><input id="line_item_description" name="line_item[description]" size="30" type="text" /></td><td><input id="line_item_price" name="line_item[price]" size="30" type="text"/></td></tr></table> <div id="line_items"> </div> <%= link_to_remote("Add Item", :update =>"line_items", :url => {:action => :say_when}, :position => "bottom") %> <!--[eoform:invoice]--> Here is my controller say_when action in the invoice controller: def say_when render_text " <table border=1> <tr> <td><input id=''line_item_description'' name=''line_item[description]'' size=''30'' type=''text'' /></td> <td><input id=''line_item_price'' name=''line_item[price]'' size=''30'' type=''text''/></td> </tr> </table>" end _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails