This repository was archived by the owner on Feb 4, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 4, 2023. It is now read-only.
Double nested entities problem #874
Copy link
Copy link
Open
Description
I've found some issues with double nested relation between entities. Entity "SiteVisit" has ManyToOne relation with "Ip", and "Ip" has ManyToOne relation with "Company".
Everything is working fine, but when i try to search by Company.name field, i get this error:
My builder fields:
$this->columnBuilder
->add('id', Column::class, [
'title' => 'Id',
'searchable' => false
])
->add('newStartedAt', DateTimeColumn::class, [
'title' => $this->translator->trans('site_visit.started_at'),
'date_format' => 'YYYY-MM-DD hh:mm:ss',
'name' => 'datefilter',
'filter' => [DateRangeFilter::class, [
'cancel_button' => true,
]],
])
->add('ip.number', Column::class, [
'title' => $this->translator->trans('ip.number'),
'filter' => [TextFilter::class,
[
'cancel_button' => true,
],
]])
->add('ip.status', Column::class, [
'title' => $this->translator->trans('ip.status'),
'filter' => [SelectFilter::class,
[
'multiple' => false,
'cancel_button' => false,
'search_type' => 'eq',
'select_options' =>
[ '' => $this->translator->trans('label.all') ]
+ $this->getOptionsArrayFromEntities($ipStatuses, 'id', 'name')
],
]])
->add('ip.country.alpha2Code', Column::class, [
'title' => $this->translator->trans('ip.country_code'),
'filter' => [TextFilter::class,
[
'cancel_button' => true,
],
]])
->add('ip.hostname', Column::class, [
'title' => $this->translator->trans('ip.hostname'),
'filter' => [TextFilter::class,
[
'cancel_button' => true,
],
]])
->add('ip.company.name', Column::class, [
'title' => $this->translator->trans('ip.company_name'),
'default_content' => '',
'filter' => [TextFilter::class,
[
'cancel_button' => true,
],
]])
->add('ip.status.name', Column::class, [
'searchable' => false,
'visible' => false,
])
->add(null, ActionColumn::class, [
'title' => '',
'actions' => [
[
'route' => 'app_site_visit_views',
'route_parameters' => ['site' => 'site.id', 'id' => 'id'],
'label' => $this->translator->trans('action.show'),
'attributes' => [
'rel' => 'tooltip',
'title' => $this->translator->trans('action.show'),
'class' => 'btn btn-action btn-sm btn-default',
'role' => 'button',
],
],
],
])
;
So as you can see, other nested relations are working fine. Relating to this issue: #826 I've aslo tried to add this fields:
->add('ip.company.id', Column::class, [
'searchable' => false,
'visible' => false,
])
->add('ip.id', Column::class, [
'searchable' => false,
'visible' => false,
])
but it's still the same. Any ideas? You can notice that company field in Ip entity is nullable.
Metadata
Metadata
Assignees
Labels
No labels

Activity
ProfM2 commentedon Feb 19, 2019
You have a couple of options.
Something like this could work for you ... (located in your EntityDatatable class)
This code would be located in your Controller for the datatable, and you would then use the QueryBuilder to join whichever tables you want. This example filters out any non-enabled users in my project.
I don't know if there is a "best-practices" for what you're trying to accomplish.