Skip to content

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

Merged
javiereguiluz merged 1 commit intoEasyCorp:4.xfrom
lacatoire:fix-collection-field-detail-7460
May 9, 2026
Merged

Skip CollectionField entry-type setup on INDEX/DETAIL pages#7594
javiereguiluz merged 1 commit intoEasyCorp:4.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

@lacatoire lacatoire force-pushed the fix-collection-field-detail-7460 branch from 3d057fe to 4420bc7 Compare May 4, 2026 13:47
@javiereguiluz javiereguiluz added this to the 4.x milestone May 9, 2026
@javiereguiluz javiereguiluz changed the base branch from 5.x to 4.x May 9, 2026 17:47
@javiereguiluz javiereguiluz force-pushed the fix-collection-field-detail-7460 branch from 4d48198 to aaf9da8 Compare May 9, 2026 17:47
@javiereguiluz
Copy link
Copy Markdown
Collaborator

Thanks for fixing this bug Louis-Arnaud.

@javiereguiluz javiereguiluz merged commit b41a560 into EasyCorp:4.x May 9, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

2 participants