EasyCorp / EasyAdminBundle

EasyAdmin is a fast, beautiful and modern admin generator for Symfony applications.
MIT License
3.99k stars 1.01k forks source link

Assets does not included for embedded crud form fields #6245

Open zorn-v opened 1 month ago

zorn-v commented 1 month ago

Describe the bug If you have collection (for example) with useEntryCrudForm and in that form you have some fields with added assets (e.g. ImageField), that assets does not included in result html page.

To Reproduce Create entities like

<?php

namespace App\Entity;

use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
class Parent
{
    #[ORM\OneToMany(mappedBy: 'parent', targetEntity: Child::class, orphanRemoval: true, cascade: ['persist', 'remove'])]
    public Collection $child;
}
<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
class Child
{
    #[ORM\ManyToOne(inversedBy: 'child')]
    #[ORM\JoinColumn(nullable: false)]
    public ?Parent $parent = null;

    #[ORM\Column(length: 255, nullable: true)]
    public ?string $photo = null;
}

and crud controllers like

// Parent
    public function configureFields(string $pageName): iterable
    {
        return [
            CollectionField::new('child')
                ->useEntryCrudForm()
        ];
    }
//...
// Child
    public function configureFields(string $pageName): iterable
    {
        return [
            ImageField::new('photo')
        ];
    }
//...

You will see that field-image.js and field-file-upload.js does not included in result html page. In fact it will not change file title for example when you select file for upload etc.

zorn-v commented 1 month ago

As workaround, include that assets in parent crud controller explicitly.