<?php
use yii\base\Model;
use yii\helpers\ArrayHelper;
public function actionBatchUpdate()
{
$items = Item::find()->all();
// Делаем ключом массива уникальное поле модели
$items = ArrayHelper::index($items, 'id');
if(Model::loadMultiple($items, $_POST) && Model::validateMultiple($items)) {
foreach ($items as $item) {
$item->save(false);
}
return $this->redirect('index');
}
// отображаем представление с формой для ввода табличных данных
return $this->render('batchUpdate', array('items'=>$items));
}
<?php
use yii\widgets\ActiveForm;
$form = ActiveForm::begin();
foreach($items as $index => $item) {
echo $form->field($item, "[$index]count");
echo $form->field($item, "[$index]price");
}
ActiveForm::end();