A
A
Alexey Verkhovtsev2017-07-28 14:56:28
Laravel
Alexey Verkhovtsev, 2017-07-28 14:56:28

Laravel array form field validation, why error?

Hello everyone, Laravel 5.1, so we immediately discard the option with *. See. This is how the name of my form name="center_id[1211]" looks like, and the center_id can be arbitrarily, the difference between them will be only in the number in brackets. Because all this in dynamics, I had to create a method, but first I decided to test the work manually on this field. Wrote like this

$this->validate($request, [
            'center_id[1211]' => 'required'
        ]);

This field is filled and you know, I get an error "The center id[1211] field is required."
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Verkhovtsev, 2017-07-28
@seftomsk

In general, everything. Array elements had to be specified through a dot

$this->validate($request, [
            'center_id.1211' => 'required'
        ]);

like this. Thanks to all. I won't delete the question, in case someone needs it :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question