Skip to content

Commit de42aa4

Browse files
committed
Fixed the autocomplete feature of association fields
1 parent a1d8c1d commit de42aa4

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Controller/AbstractCrudController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ public function autocomplete(AdminContext $context): JsonResponse
403403
/** @var CrudControllerInterface $controller */
404404
$controller = $this->get(ControllerFactory::class)->getCrudControllerInstance($autocompleteContext['crudId'], Action::INDEX, $context->getRequest());
405405
/** @var FieldDto $field */
406-
$field = FieldCollection::new($controller->configureFields(Crud::PAGE_INDEX))->get($autocompleteContext['propertyName']);
406+
$field = FieldCollection::new($controller->configureFields($autocompleteContext['originatingPage']))->get($autocompleteContext['propertyName']);
407407
/** @var \Closure|null $queryBuilderCallable */
408408
$queryBuilderCallable = $field->getCustomOption(AssociationField::OPTION_QUERY_BUILDER_CALLABLE);
409409

src/Field/Configurator/AssociationConfigurator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public function configure(FieldDto $field, EntityDto $entityDto, AdminContext $c
7676
->set(AssociationField::PARAM_AUTOCOMPLETE_CONTEXT, [
7777
'crudId' => $context->getRequest()->query->get('crudId'),
7878
'propertyName' => $propertyName,
79+
'originatingPage' => $context->getCrud()->getCurrentPage(),
7980
])
8081
->generateUrl();
8182

0 commit comments

Comments
 (0)