Tuesday, April 27, 2010

Re: model findById reads no data

Instead of just calling your show function from your edit function,
when the edit has been done successfully, you have to redirect your
application to the show function using either of the two possibilities
offered by CakePHP, as described here in the book:
http://book.cakephp.org/view/57/Controller-Methods#Flow-Control-59

Enjoy,
John

On Apr 27, 3:08 pm, cwsTrummer <christian.trum...@gmail.com> wrote:
> cakephp version 1.2.6
>
> i have model Document hasMany Page
> i have a controller called document_page_controller.php
> (pages_controller does already exists!)
>
> when i call the action show everything is fine i get an array with
> $data['Page'] and $data['Document'];
>
> function show($id)
>         {
>                 $data = $this->Page->findById($id);
>                 $this->set("data", $data);
>         }
>
> when i call edit function everything works fine too. but after i call
> $this->Page->save($this->data) i want to go back to show function.
>
> $this->Session->setFlash("Saved", "flash_success");
> $this->show($pageId);
> $this->render("show");
>
> but now i dont have any data in $data in show view. i see Page and
> Document array but all fields have a NULL value. the fields i have
> edited have the right value. i need the [Document][id] in show
> function
>
> i have already tried to call $this->Page->create(); $this->Page->id =
> null and so on. nothing works.
> when i open the show view again directly without the edit everything
> is working fine again.
>
> thanks for your help!
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions.
>
> 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 athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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: