[RESOLVED] Cakephp 3.3 How to reference in a view a property of a child of a child record (3rd level association)

Model:
Organizations hasMany Fundings
Fundings hasOne FundingDetails

Controller:
$organization = $this->Organizations-get($id,[
‘contain’ =>[
‘Fundings’,
‘Fundings.FundingDetails’,
‘Fundings.Projects’,
‘OrganiztationTypes’
]
]);
$this-> set (‘organization’, $organization);
$this-> set(‘serialize’, [‘organization’]);

View:

<?= h($fundings->fundingdetails->award_name ?> * this is where i am having problem

debugger result:

it shows perfectly that the fundingdetail entity is populated with the right data but i don’t know how to display it in view.

Also, i am to able to display just fine a nested entity of Fundings i.e. Projects just fine. i am wondering if i need to do an extrat step with a nested ‘hasOne’ versus ‘hasMany’ somewhere in my view template. there is no issue with the controller loading all the entities with its data. I just don’t know how to access the properties of that particular nested ‘hasOne’ associated entity.

thanks in advance for all your replies.

i think hasOne propertyName must be used in singular:
$fundings->fundingdetail->award_name;

thanks for your quick attention.

i had already tried that but it gives me a notice error i.e "Trying to get a property of a non-object:

what debug($organization); returns?

I also tried with 'funding_detail and still the same notice error of 'trying to get property of a non-object

debugger result:
‘funding_detail’ => object(App\Model\Entity\FundingDetail) {

			'id' => (int) 2,
			'award_amount' => (float) 500,
			'deadline' => object(Cake\I18n\FrozenDate) {

				'time' => '2018-05-30T00:00:00+00:00',
				'timezone' => 'UTC',
				'fixedNowTime' => false
			
			},
			'eligibility' => 'test_eligibility_1',
			'rule' => 'rule_eligibility_1',
			'funding_id' => (int) 69,
			'created' => object(Cake\I18n\FrozenTime) {

				'time' => '2018-05-22T11:58:22-04:00',
				'timezone' => 'America/New_York',
				'fixedNowTime' => false
			
			},
			'modified' => object(Cake\I18n\FrozenTime) {

				'time' => '2018-05-22T11:58:22-04:00',
				'timezone' => 'America/New_York',
				'fixedNowTime' => false
			
			},
			'[new]' => false,
			'[accessible]' => [
				'*' => true
			],
			'[dirty]' => [],
			'[original]' => [],
			'[virtual]' => [],
			'[errors]' => [],
			'[invalid]' => [],
			'[repository]' => 'FundingDetails'
		
		},

are your fundings in a loop?
something like this in view:

foreach ($organization->fundings as $funding) {
    echo $funding->fundingdetail->award_name;
    echo $funding->funding_detail->award_name;
}

yes, in the view, fundings is within a foreach loop structure to populate a tabular data and one of the data needs to access a child record of funding entity i.e. fundingdetails and it’s propertyname = award_name.
i’m looking to display the value of ‘award_name’

Organization hasMany Fundings
Fundings hasOne FundingDetails

FundingDetails [Entity]
award_name [property]

your debug dont show the award_name property only award_amount, its on the select?

you got it!

thanks a bunch for your prompt and quick reply.

have a wonderful day/night wherever you are.