Simple & Enhanced Input
The compact layout of UploadType, twice. On the left, the browser file input,
which uploads in the background. On the right, a list of files with thumbnails, progress,
and buttons to cancel, retry, or remove each transfer.
Simple: the browser input
layout: compact renders the browser file input. The file uploads as soon as
it is selected, and the form only submits its signed reference.
Here a small form theme removes the thumbnail, the progress bar and the buttons.
26$builder->add('document', UploadType::class, [
27 'uploader' => 'documents',
28 'layout' => 'compact',
29]);
Remove what you do not need
The theme empties the thumbnail, progress, and action blocks. The upload still runs: the field only shows the file name and its status.
Apply it to one form with form_theme, or to the whole application in
twig.yaml.
{% use '@UXUpload/form_theme.html.twig' %}
{# Keep the native file input and the file name: no thumbnail, no progress bar, no buttons. #}
{% block ux_upload_visual %}{% endblock %}
{% block ux_upload_progress %}{% endblock %}
{% block ux_upload_actions %}{% endblock %}
{% block ux_upload_summary %}{% endblock %}
Enhanced: previews and controls
The same compact input, with multiple and show_preview. Each file gets a
thumbnail, a progress bar, and buttons to cancel, retry, or remove it.
max_files caps the list; the server checks it again on submit.
26$builder->add('photos', UploadType::class, [
27 'uploader' => 'gallery',
28 'layout' => 'compact',
29 'multiple' => true,
30 'max_files' => 4,
31 'show_preview' => true,
32]);