I have the following model associations:
Response->Survey
Response->Question
Response->Choice
Survey->Question
Question->Choice
I want to create a form where I could answer all the questions for one survey. So I used the following to return the needed data:
$questions = $this->Response->Question->find('all', array(
'conditions' => array('survey_id' => $id),
'contain' => array('Choice')
)
);
Sample output for debug($questions)
.
Questions
Is there a
contain()
option so that an associated model returns in thefind('list')
format so that I could use:foreach($question as $questions) { $this->Form->select('field_name', $question['Choice']); }
If no option is available, how could I do this using PHP's builting array methods?
PS: The foreach block won't turn into a code block. If someone could edit and fix it, please do so and delete this line. Thank you.