I use EasyAdmin 3.
I'm creating a newsletter manager with Symfony 5. My entities are built as such.
- Newsletter
(ManyToOne => NewsletterItem)
- NewsletterItem
(ManyToOne => NewsletteItemSub)
- NewsletteItemSub
- NewsletterItem
In EasyAdmin, I was able to add a NewsletterItem in Newsletter. But I don't know how to add a NewsletterItemSub in NewsletterItem in EasyAdmin.
Does anyone have an idea?
My current code :
CollectionField::new('newsletterItems', 'Newsletter Items')
->allowAdd()
->allowAdd()
->setEntryIsComplex(false)
->setEntryType(NewsletterItemType::class)
->showEntryLabel(false)
->setFormTypeOptions([
by_reference' => false
]
)
->hideOnIndex(),
Create NewsletteItemSubType form class and embed it in NewsletterItemType
Something like this:
https://symfony.com/doc/current/form/form_collections.html