input.multiple2.php
Поле «Множественный список 2»
Вызывается из:
Смотрите описание Cms\Root\Form\Field\Multiple2
Исходный код
<?php
$attributes = $Field->getFieldInputAttributes(array(
'grid-margin' => $Field->getInputMargin(),
'grid-width' => $Field->getInputWidth(),
'class' => 'field-input field-input--' . $Field->type,
));
print '<span';
foreach ($attributes as $attributeName => $attributeValue) if ($attributeValue !== null) print ' ' . $attributeName . '="' . $attributeValue . '"';
print '>';
$attributes = $Field->getInputAttributes(array(
'multiple' => '',
'name' => $Field->name ? $Field->name . '[]' : $Field->name,
'placeholder' => strval($Field->placeholder) !== '' ? htmlspecialchars($Field->placeholder) : null,
'required' => $Field->required ? '' : null,
'readonly' => $Field->readonly ? '' : null,
'disabled' => $Field->disabled ? '' : null,
'class' => 'select select2 select--multiple2',
'id' => $Field->id('-input'),
'tabindex' => $Field->readonly ? '-1' : null,
));
print '<select';
foreach ($attributes as $attributeName => $attributeValue) if ($attributeValue !== null) print ' ' . $attributeName . '="' . $attributeValue . '"';
print '>';
if (is_array($Field->optionList) && count($Field->optionList)) {
$value = $Field->stringArrayValue();
foreach ($Field->optionList as $option) {
if ($option['isGroup']) {
print "\n" . '<optgroup label="' . $Field->v($option['label']) . '">';
foreach ($option['optionList'] as $option) {
print "\n" . '<option value="' . $Field->v($option['value']) . '"' . (in_array(strval($option['value']), $value, true) ? ' selected=""' : '') . '>' . $Field->v($option['label']) . '</option>';
}
print "\n" . '</optgroup>';
} else {
print "\n" . '<option value="' . $Field->v($option['value']) . '"' . (in_array($option['value'], $value, true) ? ' selected=""' : '') . '>' . $Field->v($option['label']) . '</option>';
}
}
}
print "\n" . '</select>';
print '</span>';
?>
<script>
cmsRequire(['form/script/input.select2'], init => init(document.getElementById(<?=$Field->jId('-input')?>)));
</script>