[Catalyst] OT: edit/add seperate actions?
Peter Karman
peter at peknet.com
Tue Mar 3 21:27:47 GMT 2009
Zbigniew Lukasiak wrote on 03/03/2009 02:53 PM:
>> If you use CatalystX::CRUD::REST, you can do:
>>
>> # POST /foo -> create new record
>> # GET /foo -> list all records
>> # PUT /foo/<pk> -> update record
>> # DELETE /foo/<pk> -> delete record
>> # GET /foo/<pk> -> view record
>> # GET /foo/<pk>/edit_form -> edit record form
>> # GET /foo/create_form -> create record form
>>
>> CatalystX::CRUD::REST uses the C::R::REST::ForBrowsers feature of
>> 'x-tunneled-method' param to support PUT and DELETE via POST.
>
> And where do the forms submit? I mean what is their action address?
> Do they submit to themselves - or does edit_form submit to
> /foo/<pk>?x-tunneled-method=PUT and create to /foo both with POST
> method? And it is the second - then what do you do when the form
> parameters are incorrect and you need to redisplay the form?
using the CXC REST API:
if you GET /foo/1234, then you must PUT /foo/1234 to save it.
(or POST /foo/1234?x-tunneled-method=PUT -- although I always put the
x-tunneled-method value in a hidden input body param, not as part of the
URL).
if you GET /foo/create_form, then you must POST /foo.
When the form is redisplayed on validation error, it just retains the
original action.
--
Peter Karman . peter at peknet.com . http://peknet.com/
More information about the Catalyst
mailing list