/** * Валидирует конкретное значение поля * @param string $name * @return bool */ protected function validateAttribute(\bxar\IAttribute $attribute, $setErrors = true) { $new = $this->getModel()->isNew(); if ($new) { $attrValue = $attribute->getValue(); if (is_array($this->defaultArray)) { $code = $attribute->getCode(); if (isset($this->defaultArray[$code])) { $attribute->setValue($this->defaultArray[$code]); } } else { if ($attrValue === null || $attrValue === '') { $attribute->setValue($default); } } } return true; }
/** * Валидирует конкретное значение поля * @param string $name * @return bool */ protected function validateAttribute(\bxar\IAttribute $attribute, $setErrors = true) { if (($filter = trim($this->filter)) !== '') { $attrValue = $attribute->getValue(); if (is_array($attrValue)) { $value = array_map($filter, $attrValue); } else { $value = call_user_func($filter, $attrValue); } $attribute->setValue($value); } return true; }