3

I am building simple admin panel using Easy Admin 4 and Symfony 6. Can't figure out how to preserve uploaded image value when editing entity. Image preview is not visible on Edit form also. Code is very simple:

    public function configureFields(string $pageName): iterable
    {
        return [
            IdField::new('id')->hideOnForm(),
            TextField::new('name')->setColumns(4),
            UrlField::new('url')->setColumns(4),
            ImageField::new('icon')
                ->setUploadDir('public/assets/images/')
                ->setUploadedFileNamePattern('assets/images/[slug]-[contenthash].[extension]')
                ->setColumns(4),
            TextareaField::new('description')->setColumns(12)->onlyOnForms(),
        ];
    }

Icon field is set to null on each edit. What am I missing?

Bogdan Kuštan
  • 5,427
  • 1
  • 21
  • 30
  • A bit late to the party, but I think that if EasyAdmin is not able to access the image (to get the file size and such...) the field value will be blank. It should keep the value otherwise. – Julien B. Jul 12 '23 at 15:06

1 Answers1

0

I had an issue right now that I could solve with allowing "nullable=true" for the image url property on my entity.

Seems like when "not changing" the file during edit, null is passed and this triggers an error on the validation

Xosofox
  • 840
  • 1
  • 7
  • 21