UiFormConfiguration::addFormField

  1. Bitrix24 API (v. 23.675.0)
  2. catalog
  3. UiFormConfiguration
  4. addFormField
  • Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/update/uiformconfiguration.php
  • Класс: BitrixCatalogUpdateUiFormConfiguration
  • Вызов: UiFormConfiguration::addFormField
static function addFormField(array $field, string $parentId): void
{
	if (empty($field) || !isset($field['name']) || !is_string($field['name']))
	{
		return;
	}
	if ($parentId === '')
	{
		return;
	}

	$config = static::getConfiguration();
	$formSettings = $config->get(self::PRODUCT_FORM_ID, EntityEditorConfigScope::COMMON);

	if (empty($formSettings) || !is_array($formSettings))
	{
		return;
	}

	if (static::getFieldIndex($formSettings, $field['name']) !== null)
	{
		return;
	}

	$listIndex = static::getListIndex($formSettings, $parentId);
	if ($listIndex === null)
	{
		return;
	}

	$formSettings = static::setField($formSettings, $listIndex, $field, self::SET_MODE_LAST);
	$config->set(
		self::PRODUCT_FORM_ID,
		$formSettings,
		['scope' => EntityEditorConfigScope::COMMON]
	);
	unset($config);
}

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