Skip to content

Conversation

ytilotti
Copy link
Contributor

Q A
Bug fix? no
New feature? no
Issues Fix #769
License MIT

Fix in the documentation the incompatibility between filter_query and max_results.

@carsonbot carsonbot added the Status: Needs Review Needs to be reviewed label Dec 10, 2024
@carsonbot
Copy link

It looks like you unchecked the "Allow edits from maintainer" box. That is fine, but please note that if you have multiple commits, you'll need to squash your commits into one before this can be merged. Or, you can check the "Allow edits from maintainers" box and the maintainer can squash for you.

Cheers!

Carsonbot

``filter_query`` (default: ``null``)
If you want to completely control the query made for the "search results",
use this option. This is incompatible with ``searchable_fields``::
use this option. This is incompatible with ``searchable_fields`` and ``max_results``::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch here!

Would you also update the BaseAutocompleteType code to make the same check than filter/searcheable_fields ?

$resolver->setAllowedTypes('filter_query', ['callable', 'null']);
$resolver->setNormalizer('searchable_fields', function (Options $options, ?array $searchableFields) {
if (null !== $searchableFields && null !== $options['filter_query']) {
throw new RuntimeException('Both the searchable_fields and filter_query options cannot be set.');
}
return $searchableFields;
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be a problem because max_results has default to 10.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well let's forget then :) Thanks for the fix!

@smnandre smnandre added Documentation Improvements or additions to documentation Autocomplete labels Dec 10, 2024
@smnandre smnandre changed the title fix(doc): Incompatibility filter_query and max_results [Autocomplete] Fix Incompatibility filter_query and max_results (doc) Dec 10, 2024
@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Dec 12, 2024
@smnandre
Copy link
Member

Thank you @ytilotti.

@smnandre smnandre merged commit 07cbb0b into symfony:2.x Dec 24, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Autocomplete Documentation Improvements or additions to documentation Status: Reviewed Has been reviewed by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Autocomplete] filter_query & max_results conflict

3 participants