I am submitting an array of inputs to my controller like so:
<input id="box-1-nickname" name="box-nickname[]" class="form-control" type="text" placeholder="Required">
<input id="box-2-nickname" name="box-nickname[]" class="form-control" type="text" placeholder="Required">
I am doing some validation like this:
$validator = Validator::make(Input::all(), array(
'supplies-count' => 'required|in:0,1,2,3,4',
));
$arrayValidator = Validator::make(Input::all(), []);
$arrayValidator->each('box-nickname', ['required|min:1|max:60']);
if( $validator->fails() || $arrayValidator->fails() ) {
return Redirect::route('route-2')
->withErrors($arrayValidator)
->withInput();
}
The problem is when I try to check the errors like this it doesn't work:
if( $errors->has('box-1-nickname') ) { echo ' has-error'; }
dd($errors->all())? Also, what is the point of your $arrayValidator?boxes with nobox-nicknameand submit I get this fromdd($errors->all())laravel.io/bin/vBjXvboxinputs can be added and removed dynamically on the front end so I don't know how many might be submitted.