I'm trying to do a simple ManyToMany relation between two classes with easyAdmin 3.x , when I'm trying to show entity CRUD , I have constantly this error:
The Doctrine type of the "salles" field is "4", which is not supported by EasyAdmin yet.
Th function __to string exist for the both entity
public function __toString()
{
return $this->name;
}
My CrudController:
namespace App\Controller\Admin;
use App\Entity\Batiment;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
class BatimentCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Batiment::class;
}
public function configureFields(string $pageName): iterable
{
return [
'name',
'salles'
];
}
}
Does easyadmin 3.x don't manage manytomany relations?
Is there a particular way to manage and display these relations?
I discover this bundle and thank you for your help !
In EasyAdmin 3.x a new dedicated type of fied has been added for all association mappings.
Please use something like:
namespace App\Controller\Admin;
use App\Entity\Batiment;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\Field;
class BatimentCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Batiment::class;
}
public function configureFields(string $pageName): iterable
{
return [
Field::new('id')->hideOnForm(),
Field::new('name'),
Field::new('Letter'),
ImageField::new('image'),
AssociationField::new('products')
];
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With