[Catalyst] OT: edit/add seperate actions?
Zbigniew Lukasiak
zzbbyy at gmail.com
Tue Mar 3 22:18:57 GMT 2009
On Tue, Mar 3, 2009 at 10:27 PM, Peter Karman <peter at peknet.com> wrote:
> 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).
Sure - that was just for clarification of how the PUT is done with browsers :)
>
> 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.
I was just thinking about the possible CRUD REST schemas and it found
that under that schema you display the same form under two addresses:
/foo/1234/edit_form and /foo/1234 (in case of the error). And the
other day I had that idea that perhaps instead of using path part -
use another parameter so /foo/1234?x-view-method=edit_form would
render the form and /foo/1234 would render the standard view of the
object. This way the form would have just one address.
Both things are just different representations of the same thing - so
using a parameter to differentiate between them seems quite logical.
But on the other hand it might look too different from the traditional
ways.
--
Zbigniew Lukasiak
http://brudnopis.blogspot.com/
http://perlalchemy.blogspot.com/
More information about the Catalyst
mailing list