EasyAdmin 3 编辑照片

EasyAdmin 3 Edit Photo

我有一个投资组合管理的商业实体,我使用 vichImage,但我不明白为什么我不能修改或删除图像。 我无法在不修改另一个表单域的情况下更改照片。

<?php

namespace App\Controller\Admin;

use App\Entity\Commercial;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\ImageField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Vich\UploaderBundle\Form\Type\VichImageType;

class CommercialCrudController extends AbstractCrudController
{
    public static function getEntityFqcn(): string
    {
        return Commercial::class;
    }

    public function configureCrud(Crud $crud): Crud
    {
        return $crud
            ->setPageTitle(Crud::PAGE_INDEX, 'Commercial Gallery')
            ->setPageTitle(Crud::PAGE_NEW, 'Add Photos')
            ->setPageTitle(Crud::PAGE_EDIT, 'Edit Photo')
            ->setDefaultSort(['created_at' => 'DESC']);
           
            
    }

    public function configureFields(string $pageName): iterable
    {
        // Photos configuration
        $imageFile = TextareaField::new('imageFile', 'Photo')->setFormType(VichImageType::class);
        $image = ImageField::new('commercialPhoto', 'Photo')->setBasePath('images/commercial');


        $fields = [

            IdField::new('id')->onlyOnDetail(),
            TextField::new('name', 'Services name'),
            AssociationField::new('users', 'Published by')->hideOnForm(),
            DateTimeField::new('created_at', 'Date')->hideOnForm(),

        ];

        // CRUD ACTIONS
        if ($pageName == Crud::PAGE_INDEX || $pageName == Crud::PAGE_DETAIL) {
            $fields[] = $image; // afficher l'image dans la page Index et Detail
        } else {
            $fields[] = $imageFile; // afficher l'image dans la page Edit
        }
        return $fields;
    }


    public function configureActions(Actions $actions): Actions
    {
        return $actions // Add boutton show 
            ->add(Crud::PAGE_INDEX, Action::DETAIL);
            
    }

    //create a filter 
    public function configureFilters(Filters $filters): Filters
    {
        return $filters
            ->add('name')
            ->add('users')
            ->add('created_at');
    }
}

之前加这一行就够了,现在文件改了 现在是这样的:

namespace EasyCorp\Bundle\EasyAdminBundle\Event;

/**
 * @author Javier Eguiluz <javier.eguiluz@gmail.com>
 */
final class BeforeEntityDeletedEvent extends AbstractLifecycleEvent
{
    use StoppableEventTrait;
    
    
}

当我尝试删除时,

请问我该怎么办?,我是初学者,在此先感谢您的帮助。

这只是一个拼写问题,我输入的是更新而不是更新。并删除只是添加?在 setCommercial photo 属性

中的字符串之前