12 public const DATE =
'date';
13 public const LIST =
'list';
26 public static function adapt(array $sourceField, $filterId =
''): array
28 $sourceField = static::normalize($sourceField);
29 switch ($sourceField[
'type'])
34 if (isset($sourceField[
'items']) && !empty($sourceField[
'items']) && is_array($sourceField[
'items']))
36 foreach ($sourceField[
'items'] as $selectItemValue => $selectItem)
38 if (is_array($selectItem))
40 $selectItem[
'VALUE'] = (string)$selectItemValue;
41 $listItem = $selectItem;
46 'NAME' => $selectItem,
47 'VALUE' => (string)$selectItemValue,
55 if ($sourceField[
'params'][
'multiple'])
62 $sourceField[
'placeholder']
74 elseif (empty($items[0][
'VALUE']) && empty($items[0][
'NAME']))
78 elseif (!empty($items[0][
'VALUE']) && !empty($items[0][
'NAME']))
94 $sourceField[
'placeholder']
105 $sourceField[
'name'],
106 $sourceField[
'placeholder'],
107 ($sourceField[
'time'] ??
false),
108 ($sourceField[
'exclude'] ?? []),
109 ($sourceField[
'include'] ?? []),
110 ($sourceField[
'allow_years_switcher'] ??
false),
111 ($sourceField[
'messages'] ?? [])
120 $sourceField[
'name'],
121 $sourceField[
'placeholder'],
122 ($sourceField[
'exclude'] ?? []),
123 ($sourceField[
'include'] ?? []),
124 ($sourceField[
'messages'] ?? [])
132 $sourceField[
'value'],
133 $sourceField[
'name'],
134 $sourceField[
'placeholder'],
135 ($sourceField[
'style'] ??
false)
142 $sourceField[
'name'],
143 $sourceField[
'placeholder'],
144 $sourceField[
'params'][
'multiple']
149 $values = isset($sourceField[
'valueType']) && $sourceField[
'valueType'] ===
'numeric'
167 'VALUE' => $values[0],
171 'VALUE' => $values[1],
179 $sourceField[
'name'],
180 $sourceField[
'placeholder']
192 $sourceField[
'name'],
193 $sourceField[
'placeholder'],
194 $sourceField[
'params'][
'multiple'],
195 $sourceField[
'params'],
196 ($sourceField[
'lightweight'] ??
false),
203 (
string)($sourceField[
'id'] ??
''),
204 (
string)($sourceField[
'name'] ??
''),
205 (
string)($sourceField[
'placeholder'] ??
''),
206 (isset($sourceField[
'params']) && is_array($sourceField[
'params'])) ? $sourceField[
'params'] : [],
215 $sourceField[
'name'],
216 $sourceField[
'placeholder']
225 $sourceField[
'name'],
226 $sourceField[
'placeholder']
231 if (!empty($sourceField[
'html']))
233 $field[
'HTML'] = $sourceField[
'html'];
235 if (!empty($sourceField[
'additionalFilter']))
237 $field[
'ADDITIONAL_FILTER_ALLOWED'] = $sourceField[
'additionalFilter'];
240 if (isset($sourceField[
'sectionId']) && $sourceField[
'sectionId'] !==
'')
242 $field[
'SECTION_ID'] = $sourceField[
'sectionId'];
244 if (!empty($sourceField[
'icon']))
246 $field[
'ICON'] = $sourceField[
'icon'];
256 public static function normalize(array $sourceField): array
258 if (!isset($sourceField[
'type']))
262 if (!isset($sourceField[
'placeholder']))
264 $sourceField[
'placeholder'] =
'';
266 if (!isset($sourceField[
'params']) || !is_array($sourceField[
'params']))
268 $sourceField[
'params'] = [];
270 if (!isset($sourceField[
'params'][
'multiple']))
272 $sourceField[
'params'][
'multiple'] =
false;
276 $sourceField[
'params'][
'multiple'] = (
277 $sourceField[
'params'][
'multiple'] ===
'Y'
278 || $sourceField[
'params'][
'multiple'] === true
static getMessage($code, $replace=null, $language=null)
static normalize(array $sourceField)
static adapt(array $sourceField, $filterId='')
static select($name, $items, Array $defaultValue=array(), $label="", $placeholder="")
static date( $name, $type=DateType::NONE, $values=[], $label="", $placeholder="", $enableTime=false, $exclude=[], $include=[], $allowYearsSwithcer=false, $messages=[])
static multiSelect($name, $items, $defaultValues=array(), $label="", $placeholder="")
static customEntity($name, $label="", $placeholder="", $multiple=false)
static destSelector($name, $label="", $placeholder="", $multiple=false, $params=array(), $lightweight=false, $filterName='')
static custom($name, $value, $label="", $placeholder="", $style=false)
static textarea($name, $defaultValue="", $label="", $placeholder="")
static number( $name, $type=NumberType::SINGLE, $values=[], $label="", $placeholder="", $exclude=[], $include=[], $messages=[])
static entitySelector(string $name, string $label='', string $placeholder='', array $params=[], string $filterName='')
static string($name, $defaultValue="", $label="", $placeholder="")
static customDate($options=array())