I think one of us is confused, but I'm not sure who ;)

Request action doesn't return the variables that happen to get 'set'
in that action - I mean, what if it sets 50 variables for the view,
would it return all of them in some crazy, nested array?

A better way to do what you're attempting may be to simply use the
Locations model in your Users controller, with the member variable:

var $uses=array('User', 'Location');

then you can call $this->Location->findAll() in the Users controller
too!






On Feb 9, 12:09 pm, "zafoeta" <[EMAIL PROTECTED]> wrote:
> 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