Field::isValueEmpty

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. Field
  4. isValueEmpty
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/field.php
  • Класс: Bitrix\Crm\Field
  • Вызов: Field::isValueEmpty
public function isValueEmpty($fieldValue): bool
{
	if (
		is_array ($fieldValue)
		&& in_array(\CCrmFieldInfoAttr::Multiple, $this->getAttributes(), true)
	)
	{
		foreach ($fieldValue as $singleValue)
		{
			if (!$this->isValueEmpty($singleValue))
			{
				return false;
			}
		}

		return true;
	}

	if (
		$this->type === static::TYPE_CRM_CATEGORY
		&& ($fieldValue === 0 || $fieldValue === "0")
	)
	{
		return false;
	}

	// Interpret bool 'false' as non-empty for boolean type
	if ($this->type === static::TYPE_BOOLEAN && (bool)$fieldValue === false)
	{
		return false;
	}

	if (
		($this->type === static::TYPE_INTEGER || $this->type === static::TYPE_DOUBLE)
		&& ($fieldValue === 0 || $fieldValue === 0.0 || $fieldValue === "0" || $fieldValue === "0.0" || $fieldValue === "0,0")
	)
	{
		return false;
	}

	if ($this->type === static::TYPE_STRING && $fieldValue === "0")
	{
		return false;
	}

	return empty($fieldValue);
}

Добавить комментарий