Cakephp does all that for me.
In my membersController I wrote
$this->set('categories $this->Member->Category->find('list'));
and in the add view, i just wrote:
echo $form->input('category_id');
Works like a charm =)
mig_akira wrote:
>
> Hello everyone.
>
> I have a simple question.
>
> I have a controller ('membersController') that must use 2 models ('member'
> and 'category'). A category hasMany members.
>
> When adding a member, I must choose the category it belongs to in my Add
> view. To paginate data from the Member model is simple, just
> $this->set('members', $this->paginate());
> But the problem is, I can't get the data from the Category model in my
> MembersController so that the admin can just select one among all
> categories available.
>
> I tried using, in my membersController:
>
> var $uses = array('Member ', 'Category')
>
> But in the add function, what must i use insted of
> $this->set('categories', $this->paginate()); ?
>
> Thanks!
>
--
View this message in context: http://www.nabble.com/Using-two-models-in-one-controller%2C-paginating-data-from-both-tp25285302p25288150.html
Sent from the CakePHP mailing list archive at Nabble.com.
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment