CollectionTableField in addition to CollectionField
Adding CollectionTableField to available fields
CollectionField is an amazing feature that does its job. I have a project that required to synthesize information in a table rather in widgets. This feature shall display a table with field label in table header and form widget in each cell.
Example of CollectionTableField use
Following fields pays and purchases are 2 OneToMany relations of the entity of the current Quotation entity which CRUD controller would look like the following:
class QuotationCrudController extends AbstractCrudController
{
...
public function configureFields(string $pageName): iterable
{
...
yield CollectionTableField::new('pays')
->allowAdd()
->allowDelete()
->hideOnIndex()
->useEntryCrudForm(PayCrudController::class)
;
yield CollectionField::new('purchases')
->allowAdd()
->allowDelete()
->hideOnIndex()
->useEntryCrudForm(PurchaseCrudController::class)
;
...
}
...
}
Resulting rendered form shall look like following:
This is what I came up with. It has some limitations but it works in my case, without touching EA source code. Just add the css to your CRUD and adjust the field's ->setColumns() values.