artgris / FileManagerBundle

FileManager is a simple Multilingual File Manager Bundle for Symfony
MIT License
175 stars 90 forks source link

SF4 MediaBundle / EasyAdmin : The conf was not found in artgris_file_manager #25

Closed johan-Rm closed 5 years ago

johan-Rm commented 5 years ago

Hi, I use SF4 and easyadmin, I override AdminController to add the image field but I see an error

An exception has been thrown during the rendering of a template ("The conf was not found in artgris_file_manager.") in "@ArtgrisMedia/form/field_media.html.twig".

Someone can help me ?

protected function createMediaEntityFormBuilder($entity, $view)
{
    $formBuilder = parent::createEntityFormBuilder($entity, $view);
    $formBuilder->add('image', MediaType::class)
    // ->add('imageCollection', MediaCollectionType::class)
    ;

    return $formBuilder;
}

When i make a dump in Artgris\Bundle\MediaBundle\Form\Type\MediaType.php i find conf var => false

public function buildView(FormView $view, FormInterface $form, array $options)
{
    parent::buildView($view, $form, $options);
    // dump($options);die;
    $view->vars = array_replace($view->vars, [
    'conf' => $options['conf'],
    'tree' => $options['tree'],
     'allow_alt' => $options['allow_alt'],
     'allow_crop' => $options['allow_crop'],
     'crop_options' => $options['crop_options'],
     'display_file_manager' => $options['display_file_manager'],
     ]);
 }

thanks

Arkounay commented 5 years ago

Hi, MediaType requires a 'conf' option (a conf that needs to be created in yaml through this bundle). e.g

$builder->add('image', MediaType::class, [
    'conf' => 'default'
])

and in a yaml file something like:

artgris_file_manager:
    web_dir: public
    conf:
        default:
            dir: "../public/uploads/"
            type: image

(btw, you can use ``` to format multiple lines of code)

johan-Rm commented 5 years ago

Thanks a lot