CakePHP 2.0.4 baked actions. I have reduced the generated add and edit
functions from a controller baked with CakePHP 1.3.4 and 2.0.4 to
pseudo-code below to demonstrate my question. I am basing my
expectations on the opinion I derived from studying the template
scripts, the cookbook and the links below (among others).
The qualifier [ if (!empty($this->data)) ] in the old version is
replaced by BOTH of the following in the new version:
in add function: [ if ($this->request->is('post')) ]
in edit function: [ if ($this->request->is('post') || $this->request-
>is('put')) ]
I see the difference between the two as they are but would expect the
following form:
in add function: [ if ($this->request->is('post')) ]
in edit function: [ if ($this->request->is('put')) ]
1) I think the is('post') portion of the edit function is redundant.
What is the intended functional difference between the two as they are
generated by CakePHP 2.0.4?
2) I am aware that the add view is generated _without_ the primary key
field that is included in the edit view. Does the presence/absence of
the primary key in the view served change the request/response
mechanism called?
Many TIA, McS
// 1.3.4 version of add():
if (!empty($this->data))
create record
if saved flash success; redirect; else flash failure;
// 2.0.4 version of add():
if ($this->request->is('post'))
create record
if saved flash success; redirect; else flash failure;
// 1.3.4 version of edit($id = null):
if (!$id && empty($this->data)) flash invalid; redirect;
if (!empty($this->data))
if saved flash success; redirect; else flash failure;
else read $id
// 2.0.4 version of edit($id = null):
$this->Model->id = $id;
if (!$this->Model->exists()) exception invalid;
if ($this->request->is('post') || $this->request->is('put'))
if saved flash success; redirect; else flash failure;
else read $id;
[1] http://book.cakephp.org/2.0/en/controllers/request-response.html
[2] http://www.w3.org/Protocols/rfc2616/rfc2616-sec9#sec9.5
[3] http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-16#section-7.5
[4] http://stackoverflow.com/questions/107390/whats-the-difference-between-a-post-and-a-put-http-request
[5] http://stackoverflow.com/questions/630453/put-vs-post-in-rest
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment