Skip to content

Commit

Permalink
Fix the creation of autocomplete widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Oct 31, 2023
1 parent 5bd47e0 commit 136b6c3
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
4 changes: 0 additions & 4 deletions assets/js/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ export default class Autocomplete
return this.#createAutocompleteWithHtmlContents(element);
}

// needed because choice fields can be displayed as a expanded list of
// values without autocompletion. See https://github.com/EasyCorp/EasyAdminBundle/pull/5705
if (! element.hasAttribute('value')) return;

return this.#createAutocomplete(element);
}

Expand Down
6 changes: 6 additions & 0 deletions src/Form/Filter/Type/ChoiceFilterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
{
$multiple = (bool) $builder->get('value')->getOption('multiple');

// if the filter shows the values as checkboxes or radio buttons, remove the
// attribute that turns the <select> into an autocomplete widget
if (true === ($options['value_type_options']['expanded'] ?? false)) {
unset($options['value_type_options']['attr']['data-ea-widget']);
}

$builder->addModelTransformer(new CallbackTransformer(
static fn ($data) => $data,
static function ($data) use ($multiple) {
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Resources/public/entrypoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"/app.052a1081.rtl.css"
],
"js": [
"/app.e7951020.js"
"/app.1357e916.js"
]
},
"form": {
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"app.css": "app.052a1081.css",
"app.rtl.css": "app.052a1081.rtl.css",
"app.js": "app.e7951020.js",
"app.js": "app.1357e916.js",
"form.js": "form.fc39362b.js",
"page-layout.js": "page-layout.3347892e.js",
"page-color-scheme.js": "page-color-scheme.a1970567.js",
Expand Down

0 comments on commit 136b6c3

Please sign in to comment.