Select2 is a popular jQuery plugin that makes the default HTML select element a lot more functional. With <select > element it is not possible to search on the list and add an image to an option, or customize the UI.
Select2 allows the loading of data dynamically from the server using AJAX when the user clicks on an element or search.
In this tutorial, I show how you can add select2 in CakePHP 4 and load data dynamically from the MySQL database using jQuery AJAX.