/** * Validates submitted formdata * If a record is not valid, the invalid model will be set to $model * to display error summary * * @param mixed $model * @param array $validatedItems returns the array of validated records * @param array $deleteItems returns the array of model for deleting * @param array $masterValues attributes to assign before saving * @param array $formData (default = $_POST) * @return boolean */ public static function validate($model, &$validatedItems, &$deleteItems = array(), $masterValues = array(), $formData = null) { $widget = new MultiModelForm(); $widget->model = $model; $widget->checkModel(); if (!$widget->initItems($validatedItems, $deleteItems, $masterValues, $formData)) { return false; } else { return true; } }
/** * Validates submitted formdata * If a record is not valid, the invalid model will be set to $model * to display error summary * * @param mixed $model * @param array $validatedItems returns the array of validated records * @param array $deleteItems returns the array of model for deleting * @param array $masterValues attributes to assign before saving * @param array $formData (default = $_POST) * @param null $masterModel the instance of the mastermodel will be submitted to the mmfCallbacks (fileupload, ...) * @param array $initAttributes assign virtual attributes, which are not part of attributenames and will not be assigned by setAttributes * @return bool */ public static function validate($model, &$validatedItems, &$deleteItems = array(), $masterValues = array(), $formData = null, $masterModel = null, $initAttributes = array()) { $widget = new MultiModelForm(); $widget->model = $model; $widget->masterModel = $masterModel; $widget->checkModel(); if (!$widget->initItems($validatedItems, $deleteItems, $masterValues, $formData, $initAttributes)) { $widget->saveUploadedFiles(); //saves files only if the fileattribute has no errors return false; //at least one item is not valid } else { return $widget->saveUploadedFiles(); } }