I have gone with the Model approach as it seems right.  See the
following and please give your thoughts:

Model:
...
function __formData($authUser = array()) {
  if ($authUser['User']['user_group_id'] < 3) {
    $organisations = $this->Organisation->find('list', array(
      'conditions'=>array('Organisation.is_deleted'=>'0'),
      'order'=>'Organisation.name ASC'
    ));
    $output['organisations'] = compact('organisations');
  } elseif ($authUser['User']['user_group_id'] == 3) {
    $organisations = $this->Organisation->find('list', array(
      'conditions'=>array('Organisation.is_deleted'=>'0',
'Organisation.scheme_id' => $authUser['Scheme']['id']),
      'order'=>'Organisation.name ASC'
    ));
    $output['organisations'] = compact('organisations');
  }

  $users = $this->User->find('list', array
('fields'=>'User.username'));
  $this->set(compact('users'));

  $ethnicities = $this->Ethnicity->find('list', array(
    'conditions'=>array('Ethnicity.option_list_id'=>'13'),
    'fields'=>array('Ethnicity.value'),
    'order'=>'Ethnicity.value ASC'
  ));
  $output['ethnicities'] = compact('ethnicities');

  $sexualities = $this->Sexuality->find('list', array(
    'conditions'=>array('Sexuality.option_list_id'=>'18'),
    'fields'=>array('Sexuality.value'),
    'order'=>'Sexuality.value ASC'
  ));
  $output['sexualities'] = compact('sexualities');

  $religions = $this->Religion->find('list', array(
    'conditions'=>array('Religion.option_list_id'=>'30'),
    'fields'=>array('Religion.value'),
    'order'=>'Religion.value ASC'
  ));
  $output['religions'] = compact('religions');

  $genders = $this->Gender->find('list', array(
    'conditions'=>array('Gender.option_list_id'=>'12'),
    'fields'=>array('Gender.value'),
    'order'=>'Gender.value ASC'
  ));
  $output['genders'] = compact('genders');
  return $output;
}
...

Controller:
...
$formData = $this->Referral->Client->Person->__formData($this-
>authUser);
foreach ($formData as $key => $value) {
  $this->set($formData[$key]);
}
...

I believe this fits correctly within Cake's MVC design pattern, but
I'm fully open to suggestions as to how this can be improved.

Paul.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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