Handling tabular data loading and validation in Yii 2

Comparing #5 with #6

Revision #6 was created by Kartik V Kartik V on Jan 20, 2016, 7:46:10 AM.

Added Comments

Content

[...]
public function actionBatchUpdate()
{
// retrieve items to be updated in a batch mode assuming each item
// is of model class 'Item'.
// Note the getItemsToUpdate method is an example method, where you
// fetch the valid models to update in your tabular form
. You need
 
    // to write such a method OR directly call your code to get the models.

$items=$this->getItemsToUpdate();
if (Model::loadMultiple($items, Yii::$app->request->post()) &&
Model::validateMultiple($items)) {
$count = 0;
foreach ($items as $item) {
[...]