0

im new using laravel and i get a problem. and there is my var_dump (post request)

+request: Symfony\Component\HttpFoundation\ParameterBag {#44 ▼
#parameters: array:12 [▼
  "_token" => "R1fnZMtNA55fy1plkTuztuhMZ1ExvkSw01GJq4rN"
  "spg" => "test"
  "nama" => "Reynaldo"
  "alamat" => "123"
  "hp" => "2134"
  "ccs" => "1"
  "cos" => "2"
  "oss" => "Qty"
  "tvs" => "Qty"
  "tcs" => "Qty"
  "lngs" => "Qty"
  "tks" => "Qty"
]

this if my HTML form:

@foreach ($products as $product)

        <div class="form-group row col-md-12">
            <label for="{{ $product->slug }}" class="col-sm-3 col-form-label">{{ $product->nama }}</label>
            <div class="col-sm-7">
                <select class="custom-select col-sm-2" name="{{ $product->slug }}" required>
                    <option hidden>Qty</option>
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                </select>
            </div>
        </div>

        @endforeach

the problem is, how can I modify post request (add array and don't send 'qty' value)? i want to look like this :

+request: Symfony\Component\HttpFoundation\ParameterBag {#44 ▼
#parameters: array:12 [▼
  "_token" => "R1fnZMtNA55fy1plkTuztuhMZ1ExvkSw01GJq4rN"
  "spg" => "test"
  "nama" => "Reynaldo"
  "alamat" => "123"
  "hp" => "2134"
  product array [
  "ccs" => "1"
  "cos" => "2"
  "oss" => "Qty"
  "tvs" => "Qty"
  "tcs" => "Qty"
  "lngs" => "Qty"
  "tks" => "Qty"
  ]
]

very grateful if someone helps. sorry for my broken English. thankyou.

1 Answer 1

1

try this


<select class="custom-select col-sm-2" name="{{ $product->slug }}[]" required>


now your select data come as array formate and its name will be $product->slug's name

Sign up to request clarification or add additional context in comments.

1 Comment

thanks, and now how can i filter the data (no Qty value send) ?

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.