Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yii 2 customize column with form field for editing with GridView widget

Tags:

gridview

yii2

I want the line column values in a form field so the value can be edited. I'm not trying to override the value in the database. Just want it to be editable for immediate printing.

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],



        'home_team',
        'away_team',
        'line',
        'over_under',
        'home_fd',

    ],
]); ?>
like image 839
Shawn Sonnier Avatar asked Dec 25 '22 16:12

Shawn Sonnier


1 Answers

You can specify value and format params of the DataColumn:

[
    'attribute' => 'home_team',
    'value' => function($model){
        return Html::textInput('', $model->home_team);
    },
    'format' => 'raw'
],
like image 173
Tony Avatar answered Jan 05 '23 17:01

Tony