1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Element.php
См. документацию.
1<?php
2
4
11
13{
14 public static function renderSelector(array $property, array|int|string|null $values, array $config): string
15 {
16 $rowId = trim((string)($config['ROW_ID'] ?? ''));
17 $fieldName = trim((string)($config['FIELD_NAME'] ?? ''));
18 if ($fieldName === '')
19 {
20 return '';
21 }
22
23 if (($property['PROPERTY_TYPE'] ?? '') !== PropertyTable::TYPE_ELEMENT)
24 {
25 return '';
26 }
27
28 $containerId =
29 $rowId . ($rowId !== '' ? '_' : '')
30 . $fieldName . '_container'
31 ;
32
33 if (!is_array($values))
34 {
35 $values = !empty($values) ? [$values] : [];
36 }
38
39 $multiple = ($property['MULTIPLE'] ?? 'N') === 'Y';
40
41 $config['SEARCH_TITLE'] = (string)($config['SEARCH_TITLE'] ?? '');
42 if ($config['SEARCH_TITLE'] === '')
43 {
44 $config['SEARCH_TITLE'] = Loc::getMessage('IBLOCK_UI_INPUT_ELEMENT_SELECTOR_SEARCH_TITLE');
45 }
46 $config['SEARCH_SUBTITLE'] = (string)($config['SEARCH_SUBTITLE'] ?? '');
47 if ($config['SEARCH_SUBTITLE'] === '')
48 {
49 $config['SEARCH_SUBTITLE'] = Loc::getMessage('IBLOCK_UI_INPUT_ELEMENT_SELECTOR_SEARCH_SUBTITLE');
50 }
51
52 $config['ENTITY_ID'] = (string)($config['ENTITY_ID'] ?? IblockPropertyElementProvider::ENTITY_ID);
53
54 $config['CHANGE_EVENTS'] ??= [];
55 if (!is_array($config['CHANGE_EVENTS']))
56 {
57 $config['CHANGE_EVENTS'] = is_string($config['CHANGE_EVENTS']) ? [$config['CHANGE_EVENTS']] : [];
58 }
59
60 $config = Json::encode([
61 'containerId' => $containerId,
62 'fieldName' => $fieldName . ($multiple ? '[]' : ''),
63 'multiple' => $multiple,
64 'collectionType' => 'int',
65 'selectedItems' => $values,
66 'iblockId' => (int)($property['LINK_IBLOCK_ID'] ?? 0),
67 'userType' => (string)($property['USER_TYPE'] ?? ''),
68 'entityId' => $config['ENTITY_ID'],
69 'searchMessages' => [
70 'title' => $config['SEARCH_TITLE'],
71 'subtitle' => $config['SEARCH_SUBTITLE'],
72 ],
73 'changeEvents' => $config['CHANGE_EVENTS'],
74 ]);
75
76 UI\Extension::load('iblock.field-selector');
77
78 return <<<HTML
79 <div id="$containerId"></div>
80 <script>
81 (function() {
82 const selector = new BX.Iblock.FieldSelector({$config});
83 selector.render();
84 })();
85 </script>
86 HTML
87 ;
88 }
89}
const TYPE_ELEMENT
Определения propertytable.php:68
static renderSelector(array $property, array|int|string|null $values, array $config)
Определения Element.php:14
static normalizeArrayValuesByInt(&$map, $sorted=true)
Определения collection.php:150
static load($extNames)
Определения extension.php:16
Определения json.php:9
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
Определения collection.php:2
$config
Определения quickway.php:69