jeudi 25 octobre 2018

Sending the same value multiply times

I want to save multiply serial numbers with just one form. That means as an example that you have like 4 input fields where you can scan these serial numbers 1 field is required the others dont have to be filled this looks like that:

    public function store(Request $request)
{
    $this->middleware('guest');

    request()->validate([
      'serialnumber' => 'required',
      'serialnumber',

      'member_id' => 'required'
    ]);

    Ausleih::create($request->all());


    return redirect()->route('borrow.index');

}

So next up is the view where the input cames from:

            <div class="card-body">
                <form method="POST" action="">
                    @csrf

                    <div class="form-group row">
                        <label for="serialnumber" class="col-md-4 col-form-label text-md-right"></label>

                        <div class="col-md-6">
                            <input id="serialnumber" type="text" class="form-control" name="serialnumber" value="" required autofocus>
                            <br>
                            <input id="serialnumber" type="text" class="form-control" name="serialnumber" value="" autofocus>

                            @if ($errors->has('serialnumber'))
                                <span class="invalid-feedback">
                                    <strong></strong>
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="form-group row">
                      <label for="member_id" class="col-md-4 col-form-label text-md-right"></label>
                      <div class="col-md-6">

                        <input id="member_id" type="password" class="form-control" name="member_id" required>


                        @if ($errors->has('member_id'))
                        <span class="invalid-feedback">
                          <strong></strong>
                        </span>
                        @endif
                    </div>
                  </div>
                  <div class="form-group row mb-0">
                        <div class="col-md-6 offset-md-4">
                            <button type="submit" class="btn btn-primary">
                                
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

@endsection

As you can see i just made another input field to save up more then one serial number. The problem is that i just get one value not both can someone help me out with this? What do i have to change?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire