@hollanditkzn

Из-за чего выходит ошибка в виджете detailView kartik?

Виджет использую yii2-detail-view. Но у меня проблема выходит ошибка, что именно от меня просит The attribute configuration requires the "attribute" element to determine the value and display label.
Как бы я как в примерах также внес value
Вот что я написал в коде
<?= DetailView::widget([
			'model' => $model,
			'mode' => 'view',
			'attributes' => [
				[
					'attribute' => 'srok',
					'format' => ['date','d.MM.Y'],
				],
				[
					'attribute' => 'statusName',
					'label' => 'Этап',
				],
				'columns' => [
					[
						'attribute' => 'oplata',
						'valueColOptions' => ['style' => 'width:30%']
					],
					[
						'attribute' => 'fact_oplata',
						'valueColOptions' => ['style' => 'width:30%']
					],
				],
			],
		]) ?>
  • Вопрос задан
  • 181 просмотр
Решения вопроса 1
qonand
@qonand
Software Engineer
с виджетом не работал но по всей видимости Вы не там разместили массив columns, надо так:
<?= DetailView::widget([
    'model' => $model,
    'mode' => 'view',
    'attributes' => [
        [
            'attribute' => 'srok',
            'format' => ['date','d.MM.Y'],
        ],
        [
            'attribute' => 'statusName',
            'label' => 'Этап',
        ],
        [
            'attribute' => oplata,
            'columns' => [
                [
                    'attribute' => 'oplata',
                    'valueColOptions' => ['style' => 'width:30%']
                ],
                [
                    'attribute' => 'fact_oplata',
                    'valueColOptions' => ['style' => 'width:30%']
                ],
            ],
        ]
    ],
]) ?>
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
webinar
@webinar Куратор тега Yii
Учим yii: https://youtu.be/-WRMlGHLgRg
В attributes должны содержаться все атрибуты, а у Вас всплывает oplata и fact_oplata которые не описаны.
Вот цитата из доков:
attributes - array, the most important part of this widget configuration, this is a list of attributes to be displayed in the detail view. Each array element represents the specification for displaying one particular attribute. All these attribute settings from the yii\widgets\DetailView are supported.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы