EasyCorp / EasyCorp/EasyAdminBundle

Feature Request: Native Support for Embedded Entity Detail View in AssociationField

Open
#7,389 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stale
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:

  1. Create a custom Twig component/service that:
    • Retrieves the field configuration from the associated entity's CRUD controller
    • Uses EntityFactory::createForEntityInstance() and FieldFactory::processFields() to generate FieldDto objects
    • Filters out layout fields and fields hidden on detail pages
    • Renders fields using EasyAdmin's render_field_contents macro
  2. Create a custom template that calls this component
  3. Configure the AssociationField to use this custom template via setTemplatePath()

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
  1. Consistency: Uses the same field configuration and rendering as the main detail page
  2. Maintainability: Changes to the associated entity's field configuration are automatically reflected
  3. Simplicity: No custom code needed for a common use case
  4. Type safety: Leverages existing EasyAdmin infrastructure
Implementation Notes
  • Should reuse existing EntityFactory and FieldFactory logic
  • 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.