DrBeef
DrBeef

Reputation: 11

Unable to find template "VichUploaderBundle:form:fields.html.twig"

Im using Symfony 4 + Easyadmin bundle and I've got a problem, not sure if its a bug or not.

What I have done: easy_admin.yaml

easy_admin:

easy_admin:
  entities:
    Category:
      class: App\Entity\Category
      list:
          fields: ["id", "name"]

      form:
        fields:
          - "name"
          - "slug"
          - "title"
          - { property: "imageFile", type: "vich_file" }
          - "description"

  design:
    form_theme:   ['VichUploaderBundle:Form:fields.html.twig', 'horizontal']

After I added design: form_theme etc.. I wil get this error: "Unable to find template "VichUploaderBundle:Form:fields.html.twig" (looked into: /Applications/MAMP/htdocs/paarden/templates, /Applications/MAMP/htdocs/paarden/vendor/symfony/twig-bridge/Resources/views/Form)."

What am I doing wrong?

Upvotes: 1

Views: 1165

Answers (1)

devOp_in_hiding
devOp_in_hiding

Reputation: 125

I spent more than 2 minutes to find out the solution from the linked question, so here is the answer from the comments in full:

Since Symfony 3.4/ upgrade to Symfony 4, the following change is necessary in easy_admin.yaml:

design:
    form_theme:   ['VichUploaderBundle:Form:fields.html.twig', 'horizontal']

should be

design:
    form_theme:   ['@VichUploader/Form/fields.html.twig', 'horizontal']

The reason was pointed out in the comment by @Cerad: the twig namespaces paths were adapted to the twig convention'@BundleName/dir/twigfile.twig.

Upvotes: 0

Related Questions