EasyAdminBundle 3:collection field with entity

I have two classes:

class Product {
     * @ORMOneToMany(targetEntity=Keyword::class, mappedBy="product")
    private $keywords;

class Keyword {
     * @ORMColumn(type="string", length=255)
    private $description;

     * @ORMManyToOne(targetEntity=Product::class, inversedBy="keywords")
    private $product;

In my CRUD controller of Product I defined:

public function configureFields(string $pageName): iterable
     yield CollectionField::new('keywords');

and it properly shows all the keywords but when I try to save it I get an error:

Expected argument of type "AppEntityKeyword", "string" given at property path "keywords".

Is there a possibility to show such a connection as a Collection? It would be MUCH easier to manage keywords that way.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *