Symfony EasyAdmin Dropzone领域

发布于 2025-01-28 22:57:25 字数 203 浏览 5 评论 0原文

Symfony EasyAdmin有没有办法配置类型的Symfony UX Dropzone?

我使用了此方法,但是当我拖放时,预览图像没有显示任何帮助

yield Field::new('imageFile')
->onlyOnForms()
->setFormType(DropzoneType::class);

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);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜妞爱困 2025-02-04 22:57:25

只需在dashboardController中添加这些行扩展Appact abractdashboard Controller
您的WebPack条目的名称是“应用程序”

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

    public function configureCrud(): Crud
    {
        return parent::configureCrud()
            ->addFormTheme('@Dropzone/form_theme.html.twig')
            ;
    }

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')
            ;
    }
幸福丶如此 2025-02-04 22:57:25

我已经找到了一种实现这一目标的方法;

  1. 您必须
twig:
    paths: 
        '%kernel.project_dir%/vendor/symfony/ux-dropzone/templates': CustomDropzoneNamespace
  1. regissh主题使用dropzoneType(如果需要的话,或在全球范围内):
yield Field::new('imageFile')
    ->setFormType(DropzoneType::class,)
    ->addFormTheme('@CustomDropzoneNamespace/form_theme.html.twig')
  1. 必须确保将impoulux-ux正确加载到EasyAdmin中:
public function configureAssets(): Assets
    {
        return Assets::new()
            ->addWebpackEncoreEntry('backend');
    }

其中“后端”是一个加载刺激js控制器

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文