- Модуль: catalog
- Путь к файлу: ~/bitrix/modules/catalog/lib/product/systemfield.php
- Класс: BitrixCatalogProductSystemField
- Вызов: SystemField::renderAdminEditForm
static function renderAdminEditForm(array $product, array $config): ?string
{
if (!isset($product['ID']) || !isset($product['IBLOCK_ID']) || !isset($product['TYPE']))
{
return null;
}
$product['IBLOCK_ID'] = (int)$product['IBLOCK_ID'];
if ($product['IBLOCK_ID'] <= 0)
{
return null;
}
$product['PRODUCT_ID'] = (int)($product['PRODUCT_ID'] ?? CIBlockElement::GetRealElement($product['ID']));
$product['TYPE'] = (int)$product['TYPE'];
$config['FROM_FORM'] = $config['FROM_FORM'] ?? false;
$config['ALLOW_EDIT'] = $config['ALLOW_EDIT'] ?? true;
$systemFields = self::getFieldsByRestrictions(
[
'TYPE' => $product['TYPE'],
'IBLOCK_ID' => $product['IBLOCK_ID'],
],
[
'RESULT_MODE' => self::DESCRIPTION_MODE_CLASSNAME,
]
);
if (empty($systemFields))
{
return '';
}
$userFieldManager = MainUserFieldInternalUserFieldHelper::getInstance()->getManager();
$userFields = $userFieldManager->GetUserFields(
CatalogProductTable::getUfId(),
$product['PRODUCT_ID'],
LANGUAGE_ID
);
if (empty($userFields))
{
return '';
}
$result = '';
/**
* @var string $fieldName
* @var CatalogProductSystemFieldBase $className
*/
foreach ($systemFields as $fieldName => $className)
{
$row = $userFields[$fieldName];
$row['VALUE_ID'] = $product['PRODUCT_ID'];
$row['EDIT_FORM_LABEL'] = $row['EDIT_FORM_LABEL'] ?? $row['FIELD_NAME'];
if (!$config['ALLOW_EDIT'])
{
$row['EDIT_IN_LIST'] = 'N';
}
$html = $className::renderAdminFormControl($row, $product, $config);
if ($html !== null)
{
$result .= $html;
}
}
unset($row, $fieldName);
return $result;
}