Skip to content

Commit

Permalink
Added attributes parameter to CActiveForm::validate().
Browse files Browse the repository at this point in the history
  • Loading branch information
qiang.xue committed Feb 16, 2010
1 parent d26bf8f commit 2adf5b1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions framework/web/widgets/CActiveForm.php
Expand Up @@ -489,9 +489,13 @@ public function radioButtonList($model,$attribute,$data,$htmlOptions=array())
* @param mixed a single model instance or an array of models.
* @param boolean whether to load the data from $_POST array in this method.
* If this is true, the model will be populated from <code>$_POST[ModelClass]</code>.
* @param array list of attributes that should be validated. Defaults to null,
* meaning any attribute listed in the applicable validation rules of the models should be
* validated. If this parameter is given as a list of attributes, only
* the listed attributes will be validated.
* @return string the JSON representation of the validation error messages.
*/
public static function validate($models, $loadInput=true)
public static function validate($models, $loadInput=true, $attributes=null)
{
$result=array();
if(!is_array($models))
Expand All @@ -500,7 +504,7 @@ public static function validate($models, $loadInput=true)
{
if($loadInput && isset($_POST[get_class($model)]))
$model->attributes=$_POST[get_class($model)];
$model->validate();
$model->validate($attributes);
foreach($model->getErrors() as $attribute=>$errors)
$result[CHtml::activeId($model,$attribute)]=$errors;
}
Expand Down

0 comments on commit 2adf5b1

Please sign in to comment.