H
H
hollanditkzn2017-05-29 13:08:40
Yii
hollanditkzn, 2017-05-29 13:08:40

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

2 answer(s)
M
Maxim Fedorov, 2017-05-29
@hollanditkzn

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%']
                ],
            ],
        ]
    ],
]) ?>

M
Maxim Timofeev, 2017-05-29
@webinar

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 question

Ask a Question

731 491 924 answers to any question