cakephp - Contained records only 1 level deep for afterFind? -


i have schedule hasmany events. each event belongsto room.

i set options contain'd find::

    $options = array(             'conditions' => array('schedule.' . $this->schedule->primarykey => $id),             'contain' => array(                 'event' => array(                     'room'             // etc. 

i find using:

$sched = $this->schedule->find('first', $options); 

i have afterfind method defined on event's model; in copy room's name event's displayname event can identify room it's in.

the problem: in afterfind method event has no subsidiary records. specifically, has no room record. if normal/non-contain'd find (with $this->schedule->recursive field set 3) see room's data.

is there way contain fetch data of related record before afterfind method called?

imho, i'm guessing reason want copy room name event's display name view?

may suggest alternative approach problem?

i think far simpler create view helper assist on rendering event associated room information. doesn't have complex, example:

in view:

echo $this->event->displayname($eventrecord) 

given depth of documentation relating containable behavior, pure black-magic how works , wouldn't want modify of code propose. totally appreciate you're trying achieve sticking principles of kiss, seems right advice give.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -