1

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

0

1 Answer 1

2

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 => ""
        ]
      ]
    ]
  ]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.