symfony树枝形式主题

时间:2019-12-30 08:11:47

标签: php symfony bootstrap-4 twig

我有一个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>

我的问题是变量trexecuted 您有什么想法要对此提出建议吗?

1 个答案:

答案 0 :(得分:0)

{% set tr = 'user.edit.select_image'|trans %}

trans过滤器