that seems ok. What are you missing?
Jun 3, 2022
2
Level 1
Validation array [select option]
Hello! I have the next problem I have previously used the Array Input validation in forms but with text inputs, currently I make the same structure but with select option and for some reason it does not take them into account in the validation, I want to think that it is because the title only says array Input but then I would like to request support to know how I can validate my select option array
<div class="grid grid-cols-6 gap-6">
<div class="col-span-6 sm:col-span-2">
<label for="" class="block text-sm font-semibold text-gray-700">Competidor 1</label>
<select name="competitors[1][name]" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" multiple>
<option selected disabled>Selecciona una opción</option>
<option value="competidor1">Competidor 1</option>
<option value="competidor2">Competidor 2</option>
</select>
</div>
<div class="col-span-6 sm:col-span-2">
<label for="" class="block text-sm font-semibold text-gray-700">Competidor 2</label>
<select name="competitors[2][name]" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">
<option selected disabled>Selecciona una opción</option>
<option value="competidor1">Competidor 1</option>
<option value="competidor2">Competidor 2</option>
</select>
</div>
</div>
Validation code
public function rules()
{
return [
'competitors.*.name' => 'required',
];
}
I wish you can support me, have a nice day
Please or to participate in this conversation.