Created
August 1, 2012 08:41
-
-
Save speedygfw/3225082 to your computer and use it in GitHub Desktop.
Validate multiple Models in Yii (generic)
This file contains hidden or 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
<?php | |
/** | |
* validateModels | |
* @param array $models | |
* @return boolean $valid | |
*/ | |
function validateModels(array $models) | |
{ | |
$valid = true; | |
foreach ($models as $key => $model) { | |
$models[$key]->attributes = $_POST[get_class($model)][$key]; | |
$valid = $model->validate() && $valid; | |
} | |
return $valid; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment