I've made a request validation which utilizes laravel 5.2's ability to easily validate multidimensional arrays in forms. In my custom validation request i've overridden the default rules and response methods like so:
The rules method loops through the form input, a single rule in the loop is validated something like this (slightly simplified):
$rules['from' . '.' . $field->name . '.*'] = required;
As you can see it is an array with two sublayers, an example of such a form value is:
"from" => array:4 [▼
"collection1" => array:4 [▼
0 => "some_value"
1 => "some_other_value"
The validation itself works like a charm, but returning the input to the form does not. In the response method the optional withinput() parameter gives an array to string conversion: "htmlentities() expects parameter 1 to be string, array given"
I'm not sure what withinput exactly does, and how it tries to put back the data in the correct fields. What should my form look like to comply with the withinput method? I can understand it has a hard time with a form which has form field with names like this:
from[collection1][]
from[collection1][]
to[collection1][]
to[collection1][]
Any suggestions?