A
A
Alexander2015-05-26 13:49:47
Yii
Alexander, 2015-05-26 13:49:47

Throw a couple of ideas to solve the problem?

<table class="table table-bordered">
                <thead>
                <tr>
                    <th colspan="5" align="center">
                            <h3><center><?=Yii::t("UI","Информация об сходах граждан действующих {districtname}",['{districtname}'=>$model->region->{'name_'.Yii::app()->language}])?></center></h3>
                    </th>
                </tr>
                </tr>
                </thead>
                <tbody>
            <?php
             $this->widget('zii.widgets.CListView', array(
                'dataProvider'=>$dataProvider,
                 'itemView'=>'mahala/_detail',
               ));
            }}
        ?>
                </tbody>
            </table>

A simple widget and a simple data output from the database. There is also a search by name, one input where the user writes, for example, the name of his boss and the data is displayed. Everything works, but if suddenly Vasya Vokulenko writes to the user and in a friend in two fields of the name_ru database there will be the same names but these people are from different companies. Then the error Trying to get property of non-object comes out and referring to the error here
<?=Yii::t("UI","Information about gatherings of citizens acting {districtname}",['{districtname}'=>$model ->region->{'name_'.Yii::app()->language}])?>
I understand in $model->region->{'name_'.Yii::app()->language} ] come 2 names.
<?php echo count($model->region->{'name_'.Yii::app()->language});?>
            <?php for($i=0;$i<count($model->region->{'name_'.Yii::app()->language});$i++){?>

I wanted through for but the error is the same

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
matperez, 2015-05-26
@matperez

Most likely $model->region is not always filled with a suitable object. Add the $model->region !== null check to the code and if you catch it, look where the region is lost.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question