On Mon, Sep 21, 2009 at 4:47 PM, mig_akira <mig_ak...@hotmail.com> wrote: > > > hello everyone! > > I'm building a simple web page, with Auth/ACL and a few members. > > Problem is, I baked the admin part of the site, and everything works fine > except for one thing! In my users admin page, I click in "view", but it > insists in showing the view for the first user (in this case, the admin). > > In my url, it shows /users/view/7 (number of the user's ID), but it shows > the data for the user with ID == 1. > > Funny thing is, if I click EDIT instead of VIEW, it shows the correct user! > (and the URL is /users/edit/7) > > Here are the codes for the VIEWS/USERS/INDEX.CTP : > [code] > <?php > $i = 0; > foreach ($users as $user): > $class = null; > if ($i++ % 2 == 0) { > $class = ' class="altrow"'; > } > ?> > <tr<?php echo $class;?>> > <td> > <?php echo $user['User']['username']; ?> > </td> > <td> > <?php echo $user['User']['name']; ?> > </td> > <td> > <?php echo $user['User']['email']; ?> > </td> > <td class="actions"> > <?php echo $html->link(__('View', true), > array('action'=>'view', > $user['User']['id'])); ?> > <?php echo $html->link(__('Edit', true), > array('action'=>'edit', > $user['User']['id'])); ?> > <?php echo $html->link(__('Delete', true), > array('action'=>'delete', > $user['User']['id']), null, sprintf(__('Are you sure you want to delete # > %s?', true), $user['User']['id'])); ?> > </td> > </tr> > <?php endforeach; ?> > [/code]
That's the view for index(), not view(). The latter would not have a foreach loop, as you should only have a single User in your array. > And here's for the action view in the users_Controller.php: > [code] > function view($id = null) { > if (!$id) { > $this->Session->setFlash(__('Invalid User.', true)); > $this->redirect(array('action'=>'index')); > } > $this->set('user', $this->User->read(null, $id)); > } > [/code] > > What could be the problem? > Check that you're looking at the proper view file. Then, add debug($user). It's possible that the record in the database is the same for User 1 & 7. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---