Backend\Modules\FormBuilder\Engine\Model::getErrors PHP Метод

getErrors() публичный статический Метод

Get errors (optional by type).
public static getErrors ( string $type = null ) : mixed
$type string Type of error.
Результат mixed
    public static function getErrors($type = null)
    {
        $errors['required'] = FL::getError('FieldIsRequired');
        $errors['email'] = FL::getError('EmailIsInvalid');
        $errors['numeric'] = FL::getError('NumericCharactersOnly');
        $errors['time'] = FL::getError('TimeIsInvalid');
        // specific type
        if ($type !== null) {
            $type = (string) $type;
            return $errors[$type];
        } else {
            // all errors
            $return = array();
            // loop errors
            foreach ($errors as $key => $error) {
                $return[] = array('type' => $key, 'message' => $error);
            }
            return $return;
        }
    }

Usage Example

Пример #1
0
 /**
  * Parse the default error messages
  */
 private function parseErrorMessages()
 {
     // set frontend locale
     FL::setLocale(BL::getWorkingLanguage(), true);
     // assign error messages
     $this->tpl->assign('errors', BackendFormBuilderModel::getErrors());
 }