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

Aperta
#7,389 1 commento 2 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
php, symfony
Ambito
backend

Direzione di ricerca

Inizia da AssociationField e dal percorso esistente renderAsEmbeddedForm(), quindi segui EntityFactory::createForEntityInstance(), FieldFactory::processFields() e la macro render_field_contents. Il lavoro è completo quando è disponibile un’API nativa per la pagina di dettaglio che riutilizzi la configurazione di dettaglio del CRUD associato, escluda i campi nascosti e di layout e gestisca le associazioni null; l’issue non indica file o test specifici.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

stale
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

Lingua principale
PHP
Stelle
4.3k
Fork
1.1k
Merge medio
2g 9h
PR unite (30g)
52

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di EasyCorp/EasyAdminBundle

Tutte le issue di EasyCorp/EasyAdminBundle

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.