Fields::getTabletFormattedFieldItems

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. Fields
  4. getTabletFormattedFieldItems
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/webform/options/fields.php
  • Класс: Bitrix\Crm\WebForm\Options\Fields
  • Вызов: Fields::getTabletFormattedFieldItems
private function getTabletFormattedFieldItems(array $options)
{
	$result = [];
	if (empty($options['items']))
	{
		return $result;
	}

	foreach ($options['items'] as $item)
	{
		$data = [
			'ID' => $item['value'],
			'VALUE' => $item['label'],
			'SELECTED' => ($item['selected'] ?? false) ? 'Y' : 'N',
		];

		$disabled = $item['disabled'] ?? false;
		if ($disabled)
		{
			$data['DISABLED'] = $disabled ? 'Y' : 'N';
		}

		if ($options['type'] === 'product')
		{
			$data += [
				'PRICE' => $item['price'],
				'CUSTOM_PRICE' => ($item['changeablePrice'] && WebForm\Manager::isOrdersAvailable()) ? 'Y' : 'N',
				'DISCOUNT' => $item['discount'],
				'QUANTITY' => [
					'min' => (int)($item['quantity']['min'] ?? 0),
					'max' => (int)($item['quantity']['min'] ?? null),
					'step' => (int)($item['quantity']['min'] ?? 1),
					'unit' => ($item['value'] && is_numeric($item['value']))
						? ($item['quantity']['unit'] ?? null)
						: null,
				],
			];
		}

		$result[] = $data;
	}

	return $result;
}

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