EasyCorp / EasyCorp/EasyAdminBundle
Feature Request: Native Support for Embedded Entity Detail View in AssociationField
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 4.3k
- Forks
- 1.1k
- Avg merge
- 8d 2h
- Merged PRs (30d)
- 11
Description
Use Case
When displaying an associated entity in a detail page, we often want to show all its fields directly in the detail view, not just a link. This is similar to renderAsEmbeddedForm() for forms, but for detail pages.
Current Workaround
To achieve this, we need to:
- Create a custom Twig component/service that:
- Retrieves the field configuration from the associated entity's CRUD controller
- Uses
EntityFactory::createForEntityInstance()andFieldFactory::processFields()to generateFieldDtoobjects - Filters out layout fields and fields hidden on detail pages
- Renders fields using EasyAdmin's
render_field_contentsmacro
- Create a custom template that calls this component
- Configure the
AssociationFieldto use this custom template viasetTemplatePath()
This works but requires significant boilerplate and deep knowledge of EasyAdmin internals.
Proposed Solution
Add a method similar to renderAsEmbeddedForm() but for detail pages:
yield AssociationField::new('fitnessProfile')
->renderAsEmbeddedDetail(FitnessProfileCrudController::class)
->onlyOnDetail();
This would:
- Automatically fetch and render all fields configured for the detail page of the associated entity
- Use the same field configuration, formatting, and rendering logic as the main detail page
- Maintain consistency with EasyAdmin's UI and behavior
- Handle edge cases (null associations, hidden fields, layout fields, etc.)
Benefits
- Consistency: Uses the same field configuration and rendering as the main detail page
- Maintainability: Changes to the associated entity's field configuration are automatically reflected
- Simplicity: No custom code needed for a common use case
- Type safety: Leverages existing EasyAdmin infrastructure
Implementation Notes
- Should reuse existing
EntityFactoryandFieldFactorylogic - Should respect field visibility settings (
onlyOnDetail(),hideOnDetail(), etc.) - Should filter out layout fields (tabs, panels, etc.)
- Could optionally support a subset of fields via a parameter
This would complement renderAsEmbeddedForm() and provide a native way to display embedded entity details without custom workarounds.
Thank you in advance
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with AssociationField and the existing renderAsEmbeddedForm() path, then trace EntityFactory::createForEntityInstance(), FieldFactory::processFields(), and the render_field_contents macro. Done means a native detail-page API reusing associated CRUD detail configuration while excluding hidden and layout fields and handling null associations; the issue names no specific files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, symfony
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100