Just try do this:

$this->set('products', array('one'=>'something'));
pr($products);

You will see nothing or even error.

You can use: pr($this->viewVars['products']);
But this is not directly.

So this code:
        function admin_index($id) {
                $this->Product->recursive = 0;
                $this->set('products', $this->Product-
>findAllByCategory_id($id));
                if(array_key_exists('category_id',$products)) {
                        $this->data['Category']['id'] = $products[0]
['Product']['category_id'];
                } else {
                        $this->data['Category']['id'] = $id;
                }
        }

should be changed to:
         ......
                 $products1 = $this->Product-
>findAllByCategory_id($id);
                 $this->set('products', $products1);
                 if(array_key_exists('category_id',$products1)) {
                         $this->data['Category']['id'] = $products1[0]
['Product']['category_id'];
        .......

or to:
         ......
                 $this->set('products', $this->Product-
>findAllByCategory_id($id));
                 if(array_key_exists('category_id',$this-
>viewVars['products'])) {
                         $this->data['Category']['id'] = $this-
>viewVars['products'][0]['Product']['category_id'];
                 } else {
         ......

On 25 Cze, 23:14, Nasko <[EMAIL PROTECTED]> wrote:
> > So your answer is the same as mine.
>
> Well, you could have used 3 or 4 intermediate variables along the way
> and that piece of code would still have worked. This doesn't make my
> answer the same as yours.
>
> > You can't use these variables directly in the controllers.
>
> Why not?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to