Editing Detailed View

Is there a way that I could edit a row on a detailed view like in gridview?

In gridview there’s a rowOptions property, but in detailed view there’s none.

I was going to add a bootstrap alert on a specific row in view php which is the request_status, I already tried doing this:


 <?= DetailView::widget([

        'model' => $model,

        'attributes' => function($model)

        {

            if($model->request_status == 'On Going!')

            {

                return ['class' => 'info'];

            }

        },

        'attributes' => [

            'id',

            'request_title',

            'request_details:ntext',

            'room_no',

            'assigned_to',

            'date',

            'request_status',

        ],

    ]) ?>

But it doesn’t work, is there any other way that I could do that?

The DetailView widget is for displaying values of a model’s fields. To edit them I think you need a form, for which the ActiveForm is rather good. You can mix display of the model’s fields with form inputs in one view.

There is also a problem in your PHP. The second ‘attributes’ array element overwrites the first.


php -r "var_dump(['attributes' => 'this', 'attributes' => 'that']);"

array(1) {

  ["attributes"]=>

  string(4) "that"

}

Such things you can make via css. For example, in the end of view:




if($model->request_status == 'On Going!') {

    $this->registerCss("

        // your styles, that should be applied to your table

    ");

}