How to display simple OneToMany children relation table in EasyAdmin 3 Symfony parent details page?
I trying to display table(list) of children in new panel, and cant figure it out.
You can use a template for the field
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #}
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}
{% if ea.crud.currentAction == 'detail' %}
<table>
<tr>
<th>Some Field</th>
<th>Some Other Field</th>
</tr>
{% for value in field.value %}
<tr>
<td>{{ value.someField }}</td>
<td>{{ value.someOtherField }}</td>
</tr>
{% endfor %}
</table>
{% else %}
<span class="badge badge-secondary">{{ field.formattedValue }}</span>
{% endif %}
And then just add this template to it
yield CollectionField::new('children')
->setTemplatePath('admin/fields/children.html.twig')
;