Recently I needed to add a multi-select field to a project. I used the Select2JS library to achieve just that.
Just to always remember, you can retrieve the selection with PHP (form handler) by setting the field’s name attribute to an array, e.g.:
<select name="myFieldValues[]">
Then on the PHP form handler file you can catch the fields as follows:
$valuesArray = $_POST['myFieldValues'];
Do a var_dump of the array so you can see the array.
echo '<pre>'.
var_dump($valuesArray).
'</pre>';
An array of values ‘PHP’, ‘HTML’, ‘NODEJS’, ‘WORDPRESS’, ‘WORDPRESS HOOKS’, should display as follows:
