• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/controller/measure.php
  • Класс: BitrixCatalogControllerMeasure
  • Вызов: Measure::checkDefaultValue
protected function checkDefaultValue(array $fields): Result
{
	$r = new Result();

	/**
	 * to ensure compatibility
	 * the correct option would be to mark the field as required
	 * @see BitrixCatalogRestViewMeasure::getFields().IS_DEFAULT.ATTRIBUTES.REQUIRED
	 */
	$fields['IS_DEFAULT'] = $fields['IS_DEFAULT'] ?? 'N';

	if ($fields['IS_DEFAULT'] === 'Y')
	{
		$exist = $this->existsByFilter([
			'=IS_DEFAULT' => $fields['IS_DEFAULT'],
		]);
		if ($exist->isSuccess())
		{
			$r->addError(new Error('default value can be set once [isDefault]'));
		}
	}

	return $r;
}