Answer the question
In order to leave comments, you need to log in
What causes an error in the detailView kartik widget?
Widget I use yii2-detail-view. But I have a problem with an error, what exactly is asking me for The attribute configuration requires the "attribute" element to determine the value and display label.
How would I also add value as in the examples
Here is what I wrote in the code
<?= 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%']
],
],
],
]) ?>
Answer the question
In order to leave comments, you need to log in
did not work with the widget, but apparently you placed the columns array in the wrong place, you need it like this:
<?= 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%']
],
],
]
],
]) ?>
Attributes should contain all attributes, but you have oplata and fact_oplata which are not described.
Here is a quote from the docs:
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.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question