0

I have installed VichUploaderBundle into my Symfony app and would like to have better control of the appearance of the upload buttons. I have taken the contents of fields.html.twig located in the bundle itself, and copied them into the same file at the path app/Resources/views/myControllerName/fields.html.twig This is also where all the other twig templates are for that set of controllers.

I can not seem to affect anything on the page through this method. Yes I have cleared the cache, I have even removed the cache directory.

Am I placing the file in the wrong place?

jkucharovic
  • 4,214
  • 1
  • 31
  • 46
Rick Mason
  • 311
  • 1
  • 5
  • 18

2 Answers2

2

You can override that form theme in many ways, just when you customize vich_file_widget and/or vich_image_widget e.g.:

{% extends 'base.html.twig' %}

{% form_theme form _self %}

{% block vich_file_widget %}
  {# some content… #}
{% endblock %}

{% block content %}
    {{ form(my_form) }}
{% endblock %}
jkucharovic
  • 4,214
  • 1
  • 31
  • 46
1

Thanks for the effort @jkucharovic, I was already using the 3rd method you were suggesting. My question was whether or not I put the fields.html.twig file in the correct place. Turns out I did not. For others that come along with this question, to override the fields file in the VichUploaderBundle for twig you must put a copy of the fields.html.twig file at the following path so that Symfony can override what comes with the bundle.

the fields file is found here and should not be edited...

vendor/vich/uploader-bundle/Resources/views/Form/fields.html.twig

a copy of that file should be placed here in Symfony 3. This file is editable.

app/Resources/VichUploaderBundle/views/Form/fields.html.twig

jkucharovic
  • 4,214
  • 1
  • 31
  • 46
Rick Mason
  • 311
  • 1
  • 5
  • 18