Autocomplete with custom values?
Hey!
If I read it correctly, the TextInput still allows custom values, but completes with a predefined array ( https://filamentphp.com/docs/3.x/forms/fields/text-input#autocompleting-text-with-a-datalist ) whereas the selectinput allows compley callbacks for providing the suggestions, but does not allow custom values. Is there something that does both? The TagsInput seems a great fit, but always allow multiple values. I am looking for an autocomplete that accepts a single value, which can also be custom :D
6 Replies
You want something that works like TextInput with datalist, but also filters the suggestions as you type. Am I understanding correctly?
Exactly
Or something that behaves like Select but also allows custom inputs.. I think selects UX is a bit nicer, but both works (:
The other 'solution' I found is adding the searchterm to the searchResults ^^'' but that seems super hacky
Just an idea: If TagsInput does what you want, could you add a validation rule to ensure that only one tag can be selected? Not perfect, but simple to implement.
ah, true! That could also be a way. Then I'd still need to cast that array to a string though.
The reason I was asking in the first place was, that I felt I am just blind as this looked like a common requirement, but maybe this is worth writing a plugin
I'm thinking that it would be worth adding an option to the TagsInput actually. To be able to restrict to a single item.
Yup. That would be a worthwile PR / Feature-Request maybe
I guess I will just give it a shot and draft a PR on the weekend