Last active
August 29, 2015 13:57
-
-
Save DBasic/9376908 to your computer and use it in GitHub Desktop.
Yii # actionBatchUpdate method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function actionBatchUpdate() | |
{ | |
// retrieve items to be updated in a batch mode | |
// assuming each item is of model class 'Item' | |
$items=$this->getItemsToUpdate(); | |
if(isset($_POST['Item'])) | |
{ | |
$valid=true; | |
foreach($items as $i=>$item) | |
{ | |
if(isset($_POST['Item'][$i])) | |
$item->attributes=$_POST['Item'][$i]; | |
$valid=$item->validate() && $valid; | |
} | |
if($valid) // all items are valid | |
// ...do something here | |
} | |
// displays the view to collect tabular input | |
$this->render('batchUpdate',array('items'=>$items)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment