Monday, February 6, 2012

Re: How does $this->request->is('post') works?

Hi,

At first glance you wrote an ultimate function. Try to separate
different actions to different functions.
Second thing, you check if ($action == "single") which could lead your
if ($this->request->is('post')) condition not to be checked.
Third I think your route maybe routes to different method (if there
any other at all).
Have you tried to check which methods executes when you form is
submitted?

cheers!

On febr. 6, 01:22, Fernando Nery Filho <fnfi...@gmail.com> wrote:
> Hello everyone!
>
> I'm having some trouble with the $this->request->is('post') object and
> hope I can get some answers here...
>
> In my controller I have the following:
>
> public function movie($action = "list", $id = "") {
>         if ($action == "single") {
>                 if ($this->request->is('post')) {
>                         // Saves the record
>                 } elseif ($id != "") {
>                         // Load record info
>                 } else {
>                         // Load blank form
>                 }
>
>                 // Load other informations...
>
>                 $this->render('movie');
>         }
>
> }
>
> When i load a blank form at admin/movie/single and try to submit the
> form it works just fine and my record is saved.
> But, when i load a record using admin/filme/single/1 and try to update
> it, $this->request->is('post') returns false, and nothing happens...
>
> What am I doing wrong here?

--
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: