Re: Accessing things in $this-request-data

2013-10-06 Thread Leandro Machado Pereira
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 paul.wil...@me.com

 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 cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 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 cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Accessing things in $this-request-data

2013-10-04 Thread Paul Willis
It was indeed $this-request-data['Item']['category_id']

Thanks, just had a bit of a mind block!

Paul


On 4 Oct 2013, at 01:28, Simon Males s...@sime.net.au wrote:

 Throw in a debug($this-request-data) to see what data you have.
 
 Though it's likely:
 $this-request-data['Item']['category_id']
 or
 $this-request-data('Item.category_id')
 
 
 On Fri, Oct 4, 2013 at 6:14 AM, Paul Willis paul.wil...@me.com wrote:
 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 cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
 -- 
 Simon Males
 
 -- 
 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 cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/groups/opt_out.

-- 
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 cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Accessing things in $this-request-data

2013-10-03 Thread Paul Willis
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 cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Accessing things in $this-request-data

2013-10-03 Thread Simon Males
Throw in a debug($this-request-data) to see what data you have.

Though it's likely:
$this-request-data['Item']['category_id']
or
$this-request-data('Item.category_id')


On Fri, Oct 4, 2013 at 6:14 AM, Paul Willis paul.wil...@me.com wrote:

 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 cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
Simon Males

-- 
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 cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.