/** * Валидирует конкретное значение поля * @param string $name * @return bool */ protected function validateAttribute(\bxar\IAttribute $attribute, $setErrors = true) { $value = $attribute->getValue(); /* fix at 05.10.2016, hardcode for bitrix, xml_id */ $code = $attribute->getCode(); if ($code == 'xml_id') { return true; } if ($value === null || $value === '') { $params = $attribute->getParams(); if ($setErrors) { $attribute->addError(str_replace(['#label#'], [!empty($params['NAME']) ? $params['NAME'] : ''], $this->message)); } return false; } else { return true; } }
/** * Валидирует конкретное значение поля * @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; }