Example #1
0
 /**
  * @param $value
  * @param \Bitrix\Main\Entity\Field $field
  * @param null|string $errorPhrase
  * @param null|array $additionalTemplates
  *
  * @return string
  */
 protected function getErrorMessage($value, Entity\Field $field, $errorPhrase = null, $additionalTemplates = null)
 {
     if ($errorPhrase === null) {
         $errorPhrase = $this->errorPhrase !== null ? $this->errorPhrase : Loc::getMessage($this->errorPhraseCode);
     }
     $langValues = array('#VALUE#' => $value, '#FIELD_NAME#' => $field->getName(), '#FIELD_TITLE#' => $field->getTitle());
     if (is_array($additionalTemplates)) {
         $langValues += $additionalTemplates;
     }
     return str_replace(array_keys($langValues), array_values($langValues), $errorPhrase);
 }
Example #2
0
 /**
  * @param                           $value
  * @param \Bitrix\Main\Entity\Field $field
  * @param null                      $errorPhrase
  *
  * @return mixed
  */
 protected function getErrorMessage($value, Entity\Field $field, $errorPhrase = null)
 {
     if ($errorPhrase === null) {
         $errorPhrase = $this->errorPhrase;
     }
     $langValues = array('#VALUE#' => $value, '#FIELD_NAME#' => $field->getName(), '#FIELD_TITLE#' => $field->getTitle());
     if (HasMessage($errorPhrase)) {
         return GetMessage($errorPhrase, $langValues);
     } else {
         return str_replace(array_keys($langValues), array_values($langValues), $errorPhrase);
     }
 }