Skip to content
Advertisement

Hello here i am having this problem of passing multiple data In form

As you can see here I am looping with foreach but it only sends the one product_name (last one) of the cart, but I Want to send every product_name.

<form method="POST" action="{{route('order.store')}}">
    @csrf
    @method('POST')
            
    @foreach(Cart::content() as $item)
        <input type="hidden" name="product_name" value="{{$item->name}}">
    @endforeach
</form>

            

Advertisement

Answer

You have to use like input name as array

<input type="hidden" name="product_name[]" value="{{$item->name}}">
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement