Answer the question
In order to leave comments, you need to log in
Undefined index, how to fix the error?
hello guys!!!
$positions =[
1=>Yii::t('Ui','Председатель махала'),
2=>Yii::t('Ui','Секретарь'),
3=>Yii::t('Ui','Советник'),
4=>Yii::t('Ui','Участковый')];
?>
</div><!-- search-form -->
<?php $this->widget('bootstrap.widgets.TbGridView',array(
'id'=>'ref-employees-mahala-grid ',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
array('name'=>'mahala_id', 'value'=>'$data->mahala->name_ru'),
array('name' => 'position_type','value'=> $positions[$model->position_type]),
'full_name_ru',
'full_name_uz',
'full_name_en',
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
),
),
)); ?>
Undefined index:
/var/www/alex/admin/protected/views/refEmployeesMahala/admin.php(53)
41 2=>Yii::t('Ui','Секретарь'),
42 3=>Yii::t('Ui','Советник'),
43 4=>Yii::t('Ui','Участковый')];
44 ?>
45 </div><!-- search-form -->
46 <?php $this->widget('bootstrap.widgets.TbGridView',array(
47 'id'=>'ref-employees-mahala-grid ',
48 'dataProvider'=>$model->search(),
49 'filter'=>$model,
50 'columns'=>array(
51 'id',
52 array('name'=>'mahala_id', 'value'=>'$data->mahala->name_ru'),
53 array('name' => 'position_type','value'=> $positions[$model->position_type]),
54 'full_name_ru',
55 'full_name_uz',
56 'full_name_en',
57 array(
58 'class'=>'bootstrap.widgets.TbButtonColumn',
59 ),
60 ),
61 )); ?>
Answer the question
In order to leave comments, you need to log in
Because the value on line 53 is incorrect. For an example, you can look at line 52 and the documentation.
or $model->position_type is empty or there is zero or more 4
you have $model - an object for the filter, inside TbGridView in iteration the current object is available by the $data variable.
function getPosition(id)
{
$positions = [
1=>Yii::t('Ui','Председатель махала'),
2=>Yii::t('Ui','Секретарь'),
3=>Yii::t('Ui','Советник'),
4=>Yii::t('Ui','Участковый')];
return $positions[id];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question