コード例 #1
0
ファイル: model.php プロジェクト: ziyou-liu/1line
 /**
  * Method to validate the form data.
  *
  * @param   FOFForm  $form   The form to validate against.
  * @param   array    $data   The data to validate.
  * @param   string   $group  The name of the field group to validate.
  *
  * @return  mixed   Array of filtered data if valid, false otherwise.
  *
  * @see     JFormRule
  * @see     JFilterInput
  * @since   2.0
  */
 public function validateForm($form, $data, $group = null)
 {
     // Filter and validate the form data.
     $data = $form->filter($data);
     $return = $form->validate($data, $group);
     // Check for an error.
     if ($return instanceof Exception) {
         $this->setError($return->getMessage());
         return false;
     }
     // Check the validation results.
     if ($return === false) {
         // Get the validation messages from the form.
         foreach ($form->getErrors() as $message) {
             if ($message instanceof Exception) {
                 $this->setError($message->getMessage());
             } else {
                 $this->setError($message);
             }
         }
         return false;
     }
     return $data;
 }