Saturday, July 25, 2009

Re: Edit function not giving the results I expected.

Of course, there's going to be an $id set if you pass anything into
the method. You'll need to add some logic to ensure that $id is an
integer.

On Sat, Jul 25, 2009 at 1:41 PM, number9<xpozition@gmail.com> wrote:
>
> I have just noticed something while working on an app, I use the
> following code as part of an edit function (which I believe is the
> "Cake" way:
>
>
> if (!$id && empty($this->data)) {
>        $this->Session->setFlash(__('Invalid Product', true));
>        $this->redirect(array('controller' => 'products',
> 'action'=>'index'));
> }
>
> I thought the result of this would be if a user trys to access /edit/
> foo (foo does not exist) then they would be redirect and shown an
> error message.
>
> What actually happens, is that the form appears with no data in it and
> the form actions to "/edit".
>
> I have checked a few other cake apps and it appears to be the case
> with them as well.
>
> It is a minor point, but I'm just wondering if I have to add something
> else, I'm guessing it is because /edit/$id serves as a catch all, and
> technically an ID is set...
>
> Any ideas?
>
> Thanks in advance!
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: