input.files.php
Поле «Выбор файла»
Вызывается из:
$Field->displayInput()
cms/html/input.image.php
cms/html/input.photo.php
cms/html/input.media.php
cms/html/input.flash.php
Смотрите описание Cms\Root\Form\Field\File
Исходный код
<?php
$attributes = $Field->getInputAttributes(array(
'grid-margin' => $Field->getInputMargin(),
'grid-width' => $Field->getInputWidth(),
'data-placeholder' => strval($Field->placeholder) !== '' ? htmlspecialchars($Field->placeholder) : null,
'data-required' => $Field->required ? 'Y' : null,
'data-readonly' => $Field->readonly ? 'Y' : null,
'data-disabled' => $Field->disabled ? 'Y' : null,
'class' => 'field-input field-input--files' . ($Field->type !== 'files' ? ' field-input--' . $Field->type : '') . ' input-frame with-button dropzone',
'id' => $Field->id('-input'),
'data-name' => $Field->name ? $Field->name . '[]' : $Field->name,
'data-type' => $Field->json ? 'json' : null,
'data-parent' => ($Page = $Field->Page()) && ($id = $Page->get('id')) ? htmlspecialchars($id) : null,
'data-folder' => htmlspecialchars($Field->getFolder()),
));
print '<span';
foreach ($attributes as $attributeName => $attributeValue) if ($attributeValue !== null) print ' ' . $attributeName . '="' . $attributeValue . '"';
print '>';
if (strval($Field->placeholder) !== '') {
print '<div class="dz-message input-placeholder">' . $Field->placeholder . '</div>';
}
if ($Field->name) {
$attributes = array(
'type' => 'hidden',
'name' => $Field->name . '[]',
);
foreach ($Field->arrayStringValue() as $value) {
$attributes['value'] = $Field->v($value);
print '<input';
foreach ($attributes as $attributeName => $attributeValue) if ($attributeValue !== null) print ' ' . $attributeName . '="' . $attributeValue . '"';
print '>';
}
}
print '</span>';
$enablePicker = $enableUpload = true;
if (!$Auth->login) {
$enablePicker = false;
}
if ($Field->type === 'upload2') {
$enablePicker = false;
}
$buttonNumber = 0;
if ($enablePicker) {
$buttonNumber ++;
$attributes = $Field->getButtonAttributes(array(
'type' => 'button',
'disabled' => $Field->disabled ? '' : null,
'class' => 'button-' . $buttonNumber . ' button--picker',
'id' => $Field->id('-button-' . $buttonNumber),
));
print '<button';
foreach ($attributes as $attributeName => $attributeValue) if ($attributeValue !== null) print ' ' . $attributeName . '="' . $attributeValue . '"';
print '><i class="las la-folder-open"></i></button>';
}
if ($enableUpload) {
$buttonNumber ++;
$attributes = $Field->getButtonAttributes(array(
'type' => 'button',
'disabled' => $Field->disabled ? '' : null,
'class' => 'button-' . $buttonNumber . ' button-upload no-pointer',
'id' => $Field->id('-button-' . $buttonNumber),
'tabindex' => '-1',
));
print '<button';
foreach ($attributes as $attributeName => $attributeValue) if ($attributeValue !== null) print ' ' . $attributeName . '="' . $attributeValue . '"';
print '><i class="las la-cloud-upload-alt"></i></button>';
}
?>
<script>
cmsRequire(['form/script/input.files'], init => init(document.getElementById(<?=$Field->jId('-input')?>)));
</script>