views:

77

answers:

1

I have a form in which the user can dynamically add/remove name/value pairs of fields eg:

inventory list:
[description text input field] [quantity text input field] [remove item button]
[add item button]

so basically the user can add more inventory items:

inventory list:    
[description text input field] [quantity text input field] [remove item button]
[description text input field] [quantity text input field] [remove item button]
[description text input field] [quantity text input field] [remove item button]
[add item button]

ok so what is the easiest way to save the form state if server side field validation fails, or if the user wants to later edit the custom-created form? (i don't think it is of any relevance but I am using JQuery and CakePHP)

+2  A: 

I think the best way is to use AJAX to make the request, which will prevent the client from having to re-render the entire page.

Josh Stodola
hmmm i was considering that but i want server side form validation
bananarepub
You can still use Cake's server side validation: http://www.ajaxlines.com/ajax/stuff/article/cakephp_form_validation_with_ajax_using_jquery.php
Darren Newton
Let me rephrase that for you: you *need* server-side validation. And that's no problem.
Josh Stodola