Answer the question
In order to leave comments, you need to log in
How to save data from input fields in GridView yii2?
In the GridView, I made input fields that display information (number) for positioning blocks on the site, so that if you wish, you can select positions for all blocks at once
, like this in the code
<?php
$form = ActiveForm::begin(['action' => ['main-page/sort/'],]);
echo GridView::widget([
'dataProvider' => $dataProvider,
'summary' => false,
'columns' => [
[
'attribute' => 'position',
'filter' => false,
'format' => 'raw',
'headerOptions' => ['width' => '150'],
'value' => function($model) use ($form) {
return $form->field($model, 'position')->textInput(['style' => 'width:50px'])->label(false);
}
],
'name',
?>
<div class="form-group">
<?= Html::submitButton('Сохранить позиции', ['class' => 'btn btn-default']) ?>
</div>
<?php
ActiveForm::end();
?>
return $form->field($model, 'position[]')->textInput(['style' => 'width:50px'])->label(false);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question