How to use old() in multiple select without using Form::select()

Published 7 months ago by oroalej

The title already said it all, I was able to retrieve the old form value using the Form::select(). I'm just curious if this is possible in plain html?

Also, How can you validate the multiple select? since we add "[]" to the name of the select when it's multiple, the validation doesn't work in this name. Can you guys guide me on how.

Dry7
Dry7
7 months ago (151,880 XP)

@oroalej

<select name="categories[]">
    <option value="test"{!! in_array('test', old('categories')) ? ' selected' : '' !!}>Test</option>
</select>

validation: you can use Custom Validation Rules https://laravel.com/docs/5.6/validation#custom-validation-rules

Please sign in or create an account to participate in this conversation.