Hello, When your used action add, after Item->save, the Model is updated the $this->Item->id, with the last id inserted.
Try $this->Item->id I think, the Model is updated after your save. Regards 2013/10/3 Paul Willis <[email protected]> > In my ItemsController I'm editing an item and then want to redirect back > to the category that the item is in but I'm not sure how to access the > category_id that is in $this->request->data > > My controller function (edited down to the relevant lines only) is... > > > public function admin_edit($id = null) { > if ($this->request->is('post') || > $this->request->is('put')) { > if ($this-> Item->save($this->request->data)) { > $this->Session->setFlash(__('The Item has > been saved')); > $this->redirect(array('controller' => > 'categories', 'action' => 'view', *********)); > } > } > } > > > Where I have ******* I need something like… > > $this->request-> Item->category_id > > ...to pull the category_id out but I can't get the correct syntax to use > > The category_id is in there as it is being saved with all the other item > data. > > I'm on CakePHP 2.3.x if that is relevant. > > Regards > > Paul > > -- > Like Us on FaceBook https://www.facebook.com/CakePHP > Find us on Twitter http://twitter.com/CakePHP > > --- > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/cake-php. > For more options, visit https://groups.google.com/groups/opt_out. > -- ***Se você pretende redirecionar este e-mail, por favor, apague todos os endereços que aparecem nele. Outra dica de segurança é endereçá-lo no Cco. Desta forma você estará protegendo a mim, seus amigos e a você mesmo. Eu e a Campanha Contra o SPAM agradecemos.Não envie correntes.*** -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
