zohaibh
(Zohaib1314)
1
Hi
I am trying to access the related model attributes value/label using the following code
<?= Html::activeLabel($model->profile->offices, 'number',['class'=> 'profile-page-label']); ?>
the problem is when profile table have empty office id it gives me the following error
Call to a member function formName() on a non-object
how can i by bass this error when the office id in profile table is null or not found!
Thank You
mdomba
(Maurizio Domba Cerin)
2
You need to check if [size=2]$model[/size][color=#666600][size=2]->[/size][/color][size=2]profile is set… use something like[/size]
[size=2]
[/size]
[size=2]
isset($model->profile) ? $model->profile->offices : 'n/a'
[/size]
zohaibh
(Zohaib1314)
3
when i check $model->profile it always returns true because model has related profile but when i go beyond profile by
if(isset($model->profile->offices))
it gives me the error.because office does not exist for the profile model.Now The Error is
Trying to get property of non-object