I am trying to populate fields in my edit action. I have been struggling 
with this for a full day now and can't seem to wrap my head around it. Here 
is what Ive got.


The model is Declination which belongsTo Policy. Policy hasMany 
Declination. With that said, the edit action does contain the id of a 
declination as follows (edit/xxxxxxxxx-xxxxx-xxxxxxx-xxxxxxxx)
 
Furthermore, when I debug $items they array is empty! What am I doing wrong 
or not doing at all? Any input would be greatly appreciated!




Here is my function located in my model that uses the find method for the 
declination.


         /**
 * A Policy can only have 3 declinations or none, so this method will 
return the
 * declinations that belong to the Policy in a format that will prepopulate 
the 
 * edit form correctly.
 * 
 * @access public
 * @param mixed $id (default: null)
 * @return void
 */
public function declinationsForPolicyId($id = null) {
$ret = array();
if ($id) {
$items = $this->find('all', array(
'conditions' => array(
'Declination.policy_id' => $id
),
'limit' => 3,
'contain' => array()
));
foreach ($items as $i) {
$ret[] = $i['Declination'];
}
$ret = array('Declination' => $ret);
 }
return $ret;
}

}


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to