2

In laravel 5 how do i validate an array to check if at least one value is selected - the following doesn't work?

'user_list[]'  => 'array|min:1',

{{ Form::select('user_list[]', $users, null , ['multiple' => 'multiple']) }}
2
  • Duplicate question. See stackoverflow.com/questions/30616622/… Commented Jun 3, 2015 at 12:02
  • 2
    It's not a duplicate question. This is totally different question to what you have linked. I'm asking how to check if at least one item has been selected. Your linked question is asking if a value selected exist in array. Commented Jun 3, 2015 at 16:44

1 Answer 1

5

fixed by changing the field name in the rules array as follows and by adding a required rule:

'user_list'  => 'required|array|min:1',

{{ Form::select('user_list[]', $users, null , ['multiple' => 'multiple']) }}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.