omines / datatables-bundle

DataTables bundle for Symfony
https://omines.github.io/datatables-bundle/
MIT License
262 stars 114 forks source link

OneToMany Relation / ArrayCollection - Does automatic builder handle this? #126

Closed rwkt closed 4 years ago

rwkt commented 4 years ago

A "customer" has many "phones" (ArrayCollection) - this is a OneToMany relation. The following is not working, it only seems to work when it's a ManyToOne/OneToOne relation (not an ArrayCollection).

Is there a way for the automatic builder to do it or do I need to manually build the query?

$table = $dataTableFactory->create()
            ->add('name', TextColumn::class)
            ->add('phones', TextColumn::class, ['field' => 'phone.value'])
            ->createAdapter(ORMAdapter::class, [
                'entity' => Customer::class,
            ])
            ->handleRequest($request);
curry684 commented 4 years ago

No, aggregation will need some manual handling because we do not know how you want to handle it.

rwkt commented 4 years ago

Thank you for the confirmation; and for the bundle!

curry684 commented 4 years ago

Thank you 😄 we intend to keep the bundle as "unopinionated" as possible, and that implies we should not silently handle ambiguous situations. In a situation like this we simply have no clue how to handle the array (comma based string join? subtables? <br> string join?) so it's better just to die so you as the developer know you've got to be more specific.