1

I want to use the CMF Media Bundle for image uploads. The Bundle was installed successfully.

routing.xml

cmf_media_file:
    resource: "@CmfMediaBundle/Resources/config/routing/file.xml"

cmf_media_image:
    resource: "@CmfMediaBundle/Resources/config/routing/image.xml"

AppKernel.php

$bundles = array(
   ...
   new Symfony\Cmf\Bundle\MediaBundle\CmfMediaBundle(),
);

Now I want to add the following code to my form:

$builder    
-> add('image', 'cmf_media_image', array('required' => false))
;

But I get an error message:

Could not load type "cmf_media_image"

What did i miss?

Keks
  • 11
  • 4
  • This form type only works with the phpcr storage. Did you enable phpcr either in CmfCoreBundle or on the CmfMediaBundle? – dbu Aug 11 '15 at 11:18
  • I tried to enable it: added thi following to config.xml --- cmf_media: persistence: phpcr: enabled: true --- but got an error using --- doctrine:phpcr:repository:init --- commant: "There are no commands defined in the "doctrine:phpcr:repository" namespace" – Keks Sep 01 '15 at 12:05
  • Then you are missing the doctrine/phpcr-bundle or do not instantiate it in your kernel. There is some documentation on the PHPCR bundle in http://symfony.com/doc/master/cmf/bundles/phpcr_odm/introduction.html – dbu Sep 17 '15 at 12:10
  • If you want to use ORM, you would need to look into the form type and see if you can adjust it to also work with Doctrine ORM. A pull request to make that possible would be great - ORM support for the form type is something we want but nobody had time to build it. – dbu Sep 17 '15 at 12:11
  • DId you solve this? I have same issue. Running `php app/console container:debug --tag=form.type | grep image` only shows the liip type. Very few google results for this. Followed all the instructions. Can see the fields.html.twig file in the bundle. – Martin Lyne Nov 06 '15 at 17:13

1 Answers1

0

Maybe you should declare the template like this (in config.yml) :

twig:
    form:
        resources:
            - 'CmfMediaBundle:Form:fields.html.twig'

see http://symfony.com/doc/current/cmf/bundles/media/form_types.html for more info

kondor
  • 783
  • 1
  • 8
  • 22