I have the following multi-select box in a HTML form, where user can select one or more option.
If you add a hidden input before the multiple select element, it will send the hidden input value if none of the multiple select items have been selected. As soon as you select an option though, that selected value is used instead.
This way I was able to distinguish 2 different scenarios in Laravel/php, being:
myitems to empty (requiring the hidden input, so PHP receives an empty string for myitems)myitems (so excluding any myitems input form the form. PHP will not receive the myitems key)Sample code: