我有一个Symfony表单,用于文件上传
$builder
->add('imageFile', FileType::class, [
'mapped' => false,
'required' => false,
'label' =>'user.edit.select_image',
'constraints' => $coverConstraints
])
->getForm();
由于引导程序4中有一个错误,我必须将其设置为主题,以便它可以在框中显示Select a file to upload
{% set tr = 'user.edit.select_image|trans' %}
<div class="card-body">
{{ form_start(CoverForm) }}
{{ form_row(CoverForm.imageFile, {
attr: {
'placeholder': tr
}
}) }}
{{ form_errors(CoverForm) }}
{{ form_widget(CoverForm) }}
<button type="submit" class="btn btn-dark">{{ 'user.edit.form_submit'|trans }}</button>
{{ form_end(CoverForm) }}
</div>
<script>
$('.custom-file-input').on('change', function(event) {
var inputFile = event.currentTarget;
$(inputFile).parent()
.find('.custom-file-label')
.html(inputFile.files[0].name);
});
</script>
我的问题是变量tr
不executed
您有什么想法要对此提出建议吗?
答案 0 :(得分:0)
{% set tr = 'user.edit.select_image'|trans %}
trans
是过滤器。