Hi cake-php group,

I am experiencing a rather strange problem.
I am a newbie in php and cake-php so please forgive me if this should
be a basic question.
I followed the cakephp manual, but i cannot find the error.

My problem:
I have a controller for locations which looks like this:

<?php
class LocationsController extends AppController
{
        var $name = 'Locations';
        //var $scaffold;


        function index()
        {
                $this->set('locations',$this->Location->findAll());
        }

        function view($id)
        {
                $this->set('location',$this->Location->findById($id));
        }
}
?>
Further I have a controller for users which looks like this:
<?php
class UsersController extends AppController
{
                var $name = 'Users';
                //var $scaffold;

                function index()
                {
                        $this->set('users',$this->User->findAll());
                        
$this->set('locations',$this->requestAction('/locations/index'));
                }
}
?>

As you can see above, the locations data should now be accessible in
the users view.
But if try a trivial loop over the locations in /users/index.thtml as
follows
<?php foreach ($locations as $location):
                        echo $location['Location']['location'];
                endforeach;?>

I get the warning:
Warning: Invalid argument supplied for foreach() in /var/www/html/cake/
app/views/users/index.thtml on line 42

I do not see any syntax error, also the locations view looks ok and
the code works there.


--~--~---------~--~----~------------~-------~--~----~
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