Система управления «Сайт PRO»
Версия 20240107

input.file.php

Поле «Выбор файла»

Вызывается из:

Смотрите описание Cms\Root\Form\Field\File

Исходный код
<?php

$attributes = $Field->getInputAttributes(array(
    'grid-margin' => $Field->getInputMargin(),
    'grid-width' => $Field->getInputWidth(),
    'type' => 'text',
    'name' => $Field->name,
    'value' => $Field->v(),
    'placeholder' => strval($Field->placeholder) !== '' ? htmlspecialchars($Field->placeholder) : null,
    'required' => $Field->required ? '' : null,
    'readonly' => $Field->readonly ? '' : null,
    'disabled' => $Field->disabled ? '' : null,
    'class' => 'field-input field-input--file' . ($Field->type !== 'file' ? ' field-input--' . $Field->type : '') . ' input input--file' . ($Field->type !== 'file' ? ' input--' . $Field->type : '') . ' with-button',
    'id' => $Field->id('-input'),
    'data-parent' => ($Page = $Field->Page()) && ($id = $Page->get('id')) ? htmlspecialchars($id) : null,
    'data-folder' => htmlspecialchars($Field->getFolder()),
));
print '<input';
foreach ($attributes as $attributeName => $attributeValue) if ($attributeValue !== null) print ' ' . $attributeName . '="' . $attributeValue . '"';
print '>';

$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="' . ($Field->type === 'image' ? 'las la-photo-video' : 'las la-folder-open') . '"></i></button>';

?>

<script>
cmsRequire(['form/script/input.files'], init => init(document.getElementById(<?=$Field->jId('-input')?>)));
</script>