0

is there a way in symfony easyadmin I can configureFields of type symfony ux Dropzone ??

I used this method but when I drag drop, the preview image does not show ,any help

yield Field::new('imageFile')
->onlyOnForms()
->setFormType(DropzoneType::class);
2
  • Did you end up finding a solution to this? I'm starting to see more and more of these sf questions being abandoned. Commented Mar 6, 2023 at 14:24
  • no I didn't find any solution . Commented Mar 7, 2023 at 15:21

2 Answers 2

2

Just add these lines in your DashboardController extends AbstractDashboardController Where 'app' is your webpack entry's name

    public function configureAssets(): Assets
    {
        return parent::configureAssets()
            ->addWebpackEncoreEntry('app')
        ;
    }

    public function configureCrud(): Crud
    {
        return parent::configureCrud()
            ->addFormTheme('@Dropzone/form_theme.html.twig')
            ;
    }
Sign up to request clarification or add additional context in comments.

Comments

-1

I've figured out a way to achieve this;

  1. you have to register symfony-ux dropzone form theme within twig:
twig:
    paths: 
        '%kernel.project_dir%/vendor/symfony/ux-dropzone/templates': CustomDropzoneNamespace
  1. add the form theme when using the DropzoneType (or globally if you want):
yield Field::new('imageFile')
    ->setFormType(DropzoneType::class,)
    ->addFormTheme('@CustomDropzoneNamespace/form_theme.html.twig')
  1. you have to make sure that the stimulux-ux is loaded properly within easyadmin:
public function configureAssets(): Assets
    {
        return Assets::new()
            ->addWebpackEncoreEntry('backend');
    }

where "backend" is a webpack entry that loads the stimulus js controller

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.