CRUD
CRUD copied to clipboard
Suggestion for adding an autocomplete text field
WHY
BEFORE - What was wrong? What was happening before this PR?
There were no text type fields with autocomplete.
AFTER - What is happening after this PR?
Added an autocomplete-text field which allows you to enter text and have autocompletion suggested.
HOW
How did you achieve that, in technical terms?
I took the text field and added the jquery ui load already present in the project to allow autocomplete.
I did not modify the text field because I do not think that this is a behavior that should be able to be activated on a text field. This is a very specific use in my opinion which is only used when needed.
Is it a breaking change?
No, just a suggestion for an addition.
CRUD::field('sound')
->type('autocomplete-text')
->options(["pushover", "bike", "bugle", "cashregister", "classical", "cosmic", "falling", "gamelan", "incoming", "intermission", "magic", " mechanical", "pianobar", "siren", "spacealarm", "tugboat", "alien", "climb", "persistent", "echo", "updown", "vibrate", "none"]);
How can we test the before & after?
Get the field code and use the autocomplete-text type in its crud, remembering to add a table in the options option.
Hello @dimer47 , thank you very much for this contribution, one of our members will review this suggestion to evaluate if it meets standards to add it to our main.
Thanks again.
I like this idea and the concept of a searchable text field thanks @dimer47 🙏
The code is very clean and it seems to work properly on simpler use cases.
I think this may need a little bit more work to fix edge cases like repeatable such so I don't think we can merge it as is.
I don't want to ask you to work more on this without being 100% sure we are going to do something with it in future. So allow me a few more time when we pick feature to build, to bring this to the team and decide on how to go about this.
For now it's just a file you can place in your /resources/vendor/backpack/crud/fields and use in your projects when you need it.
Will keep this open and re-evaluate in future if we want to spend time doing this as proposed, or we incorporate it as a component later.
Thanks again for the contribution @dimer47 🙏
If anyone feels this is a wanted feature please leave a comment or a thumbs up so that we can prioritize it if more people want it 🙏
Cheers
Hey @dimer47, @pxpm!
Thank you for the PR, I took a quick check on your code and it looks nice, but it uses jQuery 😅 We're trying to avoid using libraries when they're not needed, and this is a good example.
For this purpose we can use <datalist>, it's vanilla HTML, no javascript needed, and it works just as good, and it's fully supported (https://caniuse.com/?search=datalist).