I am using a 2 dimensional array of fields in Laravel 5.3. I wish to validate all the values of that as required and to display the individual error messages. I used the validation in the controller function as follows
$this->validate($request, [
'training_id' =>'required',
'survey_name' =>'required',
'question.*' =>'required',
'answer_option.*.*' =>'required'
],
['question.*.required' => 'The question field is required.',
'answer_option.*.*.required' => 'The answer field is required.']);
In the view page while i tried to display all the error messages, only the first row of answers will be validated and the others won't. The error messages are as
Array ( [0] => The question field is required. [1] => The question field is required. [2] => The answer_option.0.0 field is required. [3] => The answer_option.0.1 field is required. [4] => The answer_option.0.2 field is required. [5] => The answer_option.0.3 field is required. [6] => The training id field is required. [7] => The survey name field is required. )
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire