- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/webform/embed/config.php
- Класс: Bitrix\Crm\WebForm\Embed\Config
- Вызов: Config::appendField
public function appendField(array $options)
{
if (!empty($options['type']))
{
$isSupportedType = in_array(
$options['type'],
array_merge(
array_keys(WebForm\Helper::getFieldNonValueTypes()),
['product']
)
);
if (!$isSupportedType)
{
return; //todo: need ErrorCollection
}
$options += [
'name' => $options['type'] . '_' . mt_rand(1000000, 9999999),
'label' => WebForm\Internals\FieldTable::getTypeList()[$options['type']]
];
switch ($options['type'])
{
case 'product':
/**
* @var \CIBlockResult $iblockItems
*/
$iblockItems = \CIBlockElement::GetList(
["SORT"=>"DESC"],
[
'=IBLOCK_ID' => \CCrmCatalog::EnsureDefaultExists(),
'!==PREVIEW_PICTURE' => null,
'!==DETAIL_PICTURE' => null,
],
false,
[
'nTopCount' => 3
],
);
$items = [];
while ($item = $iblockItems->Fetch())
{
$items[] = [
'value' => $item['ID'],
'label' => $item['NAME'],
'price' => \CCrmProduct::getPrice($item['ID'])['PRICE'],
];
}
$options += [
'bigPic' => true,
'multiple' => true,
'items' => $items,
];
break;
default:
$options += [
'type' => 'layout',
'content' => ['type' => $options['type']],
] + $options;
}
}
$this->fieldsConfig->append($options);
}