Thursday, November 27, 2008

Re: accessing different models in controller

I assume there is a relation between polls and featured_poll? If so
you should be able to get them by possibly increasing your recursive
to 2 I believe. That or $this->Club->Poll->FeaturedPoll->find('all')
if there is no association add this to your controller
var $uses = array('Club','FeaturedPoll');
the uses variable says which models to load for that controller. If
you only use it once and don't want to load the the model up each time
which can slow down your controller some but not lots or anything
since you are only loading 2 models, but you can check out bindModel
in cakephp docs

On Nov 27, 10:41 pm, AngeloZanetti <angelo...@gmail.com> wrote:
> Hi guys,
>
> 3 tables:
>
> clubs, polls, featured_poll
>
> Now each club is assigned to a poll (poll_id, in clubs table).
>
> Then the featured_poll just keeps a record of which poll is featured
> currently.
>
> The problem I am having is that when we want to create a club there is a
> list of polls to choose from but we want to mark the "featured poll" as
> selected by default.
>
> However there is no association between the club and the featured_poll model
> or DB tables.
>
> Is it possible to get the value of the featured_poll table and then when
> displaying the list of poll options  just default it to that option?
>
> Am I going about this the correct way or are there are ways to accomplish
> this? Do you need me to display here my model information to give a better
> picture?
>
> thanks
> angelo
>
> --
> View this message in context:http://www.nabble.com/accessing-different-models-in-controller-tp2072...
> 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: