input.multimap.php
Поле «Список во всплывающем окне»
Вызывается из:
Смотрите описание Cms\Root\Form\Field\Multimap
Исходный код
<?php
$attributes = $Field->getFieldInputAttributes(array(
'grid-margin' => $Field->getInputMargin(),
'grid-width' => $Field->getInputWidth(),
'class' => 'field-input field-input--' . $Field->type . ' input-frame with-button',
));
print '<span';
foreach ($attributes as $attributeName => $attributeValue) if ($attributeValue !== null) print ' ' . $attributeName . '="' . $attributeValue . '"';
print '>';
$attributes = $Field->getInputAttributes(array(
'type' => 'hidden',
'name' => $Field->name,
'placeholder' => strval($Field->placeholder) !== '' ? htmlspecialchars($Field->placeholder) : null,
'required' => $Field->required ? '' : null,
'readonly' => $Field->readonly ? '' : null,
'disabled' => $Field->disabled ? '' : null,
'value' => $Field->v(),
'id' => $Field->id('-input'),
));
print '<input';
foreach ($attributes as $attributeName => $attributeValue) if ($attributeValue !== null) print ' ' . $attributeName . '="' . $attributeValue . '"';
print '>';
$values = array();
foreach ($Field->stringArrayValue() as $value) {
if ($value === '') {
continue;
} elseif ($value === '*') {
$values[$value] = $Main->translate('Все');
} elseif ($value === 'author' && $attributes['data-filter'] === 'group') {
$values[$value] = $Main->translate('Автор');
} elseif ($Item = $Main->load($value)) {
$values[$value] = $Item->displayTitle();
} else {
continue;
}
}
if (empty($values)) {
print '<span id="' . $Field->id('-visual') . '" class="input-placeholder">';
if (strval($Field->placeholder) !== '') {
print htmlspecialchars($Field->placeholder);
}
print '</span>';
} else {
print '<span id="' . $Field->id('-visual') . '">';
print trim(implode('<br>', $values));
print '</span>';
}
print '</span>';
$attributes = $Field->getButtonAttributes(array(
'type' => 'button',
'disabled' => $Field->disabled ? '' : null,
'class' => 'button-1 button--picker',
'id' => $Field->id('-button'),
));
print '<button';
foreach ($attributes as $attributeName => $attributeValue) if ($attributeValue !== null) print ' ' . $attributeName . '="' . $attributeValue . '"';
print '><i class="las la-list-ul"></i></button>';
?>
<script>
cmsRequire(['form/script/input.sitemap'], init => init(document.getElementById(<?=$Field->jId('-input')?>), { visual: document.getElementById(<?=$Field->jId('-visual')?>) }));
</script>