Skip to content

Skip CollectionField entry-type setup on INDEX/DETAIL pages#7594

Open
lacatoire wants to merge 1 commit intoEasyCorp:5.xfrom
lacatoire:fix-collection-field-detail-7460
Open

Skip CollectionField entry-type setup on INDEX/DETAIL pages#7594
lacatoire wants to merge 1 commit intoEasyCorp:5.xfrom
lacatoire:fix-collection-field-detail-7460

Conversation

@lacatoire
Copy link
Copy Markdown
Contributor

CollectionConfigurator::configureEntryType() instantiates the target CRUD controller and calls configureFields(PAGE_EDIT) on it (or PAGE_NEW) so it can build entry_type/prototype options. These options are only consumed when the field is rendered as a form: on INDEX/DETAIL the field falls back to formatCollection() which only reads the value and a custom option.

Running configureFields(PAGE_EDIT) on the target controller while displaying the parent's DETAIL page wastes work and, more importantly, runs user code with no real entity instance available, which makes controllers that legitimately read $context->getEntity()->getInstance() inside configureFields() crash on a NULL entity.

Bail out early when the current page is neither EDIT nor NEW so the form setup only happens on the pages that actually need it.

Closes #7460

CollectionConfigurator::configureEntryType() instantiates the target CRUD
controller and calls configureFields(PAGE_EDIT) on it (or PAGE_NEW) so it can
build entry_type/prototype options. These options are only consumed when the
field is rendered as a form (i.e. on NEW/EDIT pages); on INDEX/DETAIL the
field falls back to formatCollection() which only reads the value and a
custom option.

Running configureFields(PAGE_EDIT) on the target controller while displaying
the parent entity's DETAIL page does not just waste work: it also runs the
user's configureFields() with no real entity instance available, which makes
controllers that legitimately read $context->getEntity()->getInstance()
inside configureFields() crash on a NULL entity (EasyCorp#7460).

Bail out early when the current action is neither EDIT nor NEW so the form
setup only happens on the pages that actually need it.
@lacatoire lacatoire force-pushed the fix-collection-field-detail-7460 branch from 3d057fe to 4420bc7 Compare May 4, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CollectionField to another relation on detail page is calling EDIT action on crud controller of relation

1 participant