Reputation: 570
I am creating a dynamic form and hence inputs names are being created dynamically, But validation is not working properly.
Input Example:
<input type="text" id="information" name="page[home][Admin]user[]">
<input type="text" name="action[home][Admin]user[]">
Validation:
$validatedData = $request->validate([
'page'=>'required|array',
'page.*.user'=>'required',
]);
But it's not working
Upvotes: 1
Views: 1899
Reputation: 15319
try changing input name to
<input type="text" id="information" name="page[home][Admin][user][]">
and validation rules like
[
'page'=>'required|array',
'page.*.*.user.*'=>'required',
]
So Request contain page data like
"page" => array:1 [▼
"home" => array:1 [▼
"Admin" => array:1 [▼
"user" => array:2 [▼
0 => ""
]
]
]
]
Upvotes: 2