- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/webform/options.php
- Класс: Bitrix\Crm\WebForm\Options
- Вызов: Options::convertToFormOptions
private function convertToFormOptions(array $options)
{
$views = [];
$viewTypes = array_keys($this->getEmbedding()['scripts'] ?? []);
$availableOptions = self::getViewOptions();
foreach ($options['embedding']['views'] as $viewType => $view)
{
if (!in_array($viewType, $viewTypes))
{
continue;
}
$typeOptions = $availableOptions[$viewType] ?? [];
foreach ($view as $viewKey => $viewValue)
{
if (!self::checkViewOptions($viewKey, $viewValue, $typeOptions))
{
continue;
}
self::filterViewOptionValues($viewValue);
$views[$viewType][$viewKey] = $viewValue;
}
}
return [
'NAME' => $options['name'],
'TEMPLATE_ID' => $options['templateId'],
'PRESET_FIELDS' => array_map(
function ($field)
{
return [
'ENTITY_NAME' => $field['entityName'],
'FIELD_NAME' => $field['fieldName'],
'VALUE' => $field['value'],
];
},
$options['presetFields'] ?? []
),
'IS_PAY' => $options['payment']['use'] ? 'Y' : 'N',
'AGREEMENT_ID' => null,
'ENTITY_SCHEME' => (int) $options['document']['scheme'],
'DUPLICATE_MODE' => $options['document']['duplicateMode'],
'FORM_SETTINGS' => [
'DYNAMIC_CATEGORY' => $options['document']['dynamic']['category'] ?? null,
'DYNAMIC_DC_ENABLED' => ($options['document']['dynamic']['duplicatesEnabled'] ?? false) ? 'Y' : 'N',
'DEAL_CATEGORY' => $options['document']['deal']['category'],
'DEAL_DC_ENABLED' => $options['document']['deal']['duplicatesEnabled'] ? 'Y' : 'N',
'REDIRECT_DELAY' => $options['result']['redirectDelay'],
'REFILL' => [
'ACTIVE' => ($options['result']['refill']['active'] ?? false) ? 'Y' : 'N',
'CAPTION' => $options['result']['refill']['caption'] ?? '',
],
'VIEWS' => $views,
'DISABLED_PAY_SYSTEMS' => $this->convertPaySystemIds(
$options['payment']['disabledSystems'] ?? []
),
],
'ASSIGNED_BY_ID' => array_filter(
array_map(
'intval',
$options['responsible']['users'] ?? []
)
),
'ASSIGNED_WORK_TIME' => ($options['responsible']['checkWorkTime'] ?? false) ? 'Y' : 'N',
'USE_LICENCE' => $options['agreements']['use'] ? 'Y' : 'N',
'RESULT_SUCCESS_URL' => $options['result']['success']['url'],
'RESULT_SUCCESS_TEXT' => $options['result']['success']['text'],
'RESULT_FAILURE_URL' => $options['result']['failure']['url'],
'RESULT_FAILURE_TEXT' => $options['result']['failure']['text'],
'IS_CALLBACK_FORM' => $options['callback']['use'] ? 'Y' : 'N',
'CALL_FROM' => $options['callback']['from'],
'CALL_TEXT' => $options['callback']['text'],
];
}