Laravel 5.6 i want to add more fields dynamically using jquery

Posted in CategoryLaravel
  • H
    Hardik Savani 8 months ago

    You need to follow this article: and you have to change controller method this way:

    public function addMorePost(Request $request)
        $rules = [];
        foreach($request->input('name') as $key => $value) {
            $rules["name.{$key}"] = 'required';
        foreach($request->input('fateherName') as $key => $value) {
            $rules["fateherName.{$key}"] = 'required';
        $validator = Validator::make($request->all(), $rules);
        if ($validator->passes()) {
            foreach($request->input('name') as $key => $value) {
            foreach($request->input('fateherName') as $key => $value) {
            return response()->json(['success'=>'done']);
        return response()->json(['error'=>$validator->errors()->all()]);

    Try this way....

  • L
    Lasa Marndi 8 months ago

    Laravel - Dynamically Add or Remove input fields using JQuery


    if i add multiple felid then how dynamically insert data to database


    exmple: <input type="text" name=name[]>

    <input type="text" name=fateherName[]>


    any body please help me

Please login or register to leave a response.

* You May Also Like Bellow Issue to check *