I'm not suggesting this is the correct way to do it, but I would put
those methods in the model definitions to which they relate. Then they
are accessible from any controller that 'uses' that model in addition
to its own. Then you can say something like:

    $organisations= $this->Person->Organisation->formData();
    $genders = $this->Person->Gender->formData();
    ...and so on...

On Jan 27, 2:07 pm, WebbedIT <p...@webbedit.co.uk> wrote:
> Are you sure a component would be correct for this as again the
> CookBook states "To access/use a model in a component is not generally
> recommended" and my __formData() functions are made to access models:
>
> function formData() {
>   $organisations= $this->Person->Organisation->find('list', array(
>   'order'=>'Organisation.name ASC'
>   ));
>   $this->set(compact('organisations'));
>
>   $users = $this->Person->User->find('list', array
> ('fields'=>'User.username'));
>   $this->set(compact('users'));
>   $ethnicities = $this->Person->Ethnicity->find('list', array(
>   'conditions'=>array('Ethnicity.option_list_id'=>'13'),
>   'fields'=>array('Ethnicity.value'),
>   'order'=>'Ethnicity.value ASC'
>   ));
>   $this->set(compact('ethnicities'));
>
>   $sexualities = $this->Person->Sexuality->find('list', array(
>   'conditions'=>array('Sexuality.option_list_id'=>'18'),
>   'fields'=>array('Sexuality.value'),
>   'order'=>'Sexuality.value ASC'
>   ));
>   $this->set(compact('sexualities'));
>
>   $religions = $this->Person->Religion->find('list', array(
>   'conditions'=>array('Religion.option_list_id'=>'30'),
>   'fields'=>array('Religion.value'),
>   'order'=>'Religion.value ASC'
>   ));
>   $this->set(compact('religions'));
>
>   $genders = $this->Person->Gender->find('list', array(
>   'conditions'=>array('Gender.option_list_id'=>'12'),
>   'fields'=>array('Gender.value'),
>   'order'=>'Gender.value ASC'
>   ));
>   $this->set(compact('genders'));
>
> }
>
> Also I would still have to create a lot of logic or duplicate
> functions within the component so that the find calls were made via
> the right associations, i.e. the above function would work fine when
> the referencing controller was PeopleController but when called from
> ClientController the find calls would have to start $this->Client-
>
> >Person... and from Staff $this->Staff->Person... etc.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to