I am currently writing an application that will validate form data from an admin.
As far as I can see I have two option to do this:
GET and POST requests to the same URL
GET /admin/category/new
present an HTML form to create a new category
POST /admin/category/new
which POSTs here, if valid it just reloads the HTML form along
with the submitted data and relevant errors until it passes validation. However if a user refreshes they are asked by the browser to resend the data.
GET and POST to different RESTful URLs
GET /admin/category/new
present an HTML form to create a new category
POST /admin/category
which would could handles PUT
, DELETE
requests as well. If the validation fails and a user is redirected back to GET /admin/category/new
is it OK to persist both the error and previous input in session flash? What would happen if a user was submitting multiple edits across a number of browser windows. How do you ensure that previous input is attached to the right form.
The main reason I ask is that when I am updating multiple items in Magento or WordPress multiple flash messages queue in one window that relate to other windows updates. So which option is the best? or easiest to maintain?