Support the ongoing development of Laravel.io →
Database Views Forms
Last updated 2 years ago.
0
Solution

try

@foreach ($products as $i => $product)
            {!! Form::label('product', $product->longName) !!}
            {!! Form::hidden("nameEn[$i]", $product->nameEn) !!}
            {!! Form::hidden("orderNum[$i]", $orderNum) !!}
            {!! Form::hidden("price[$i]", $product->price) !!}
            {!! Form::text("qty[$i]",Input::old("qty.$i"), ['class' => 'form-control']) !!}
@endforeach
Last updated 8 years ago.
0

Lewolf said:

try

@foreach ($products as $i => $product)
           {!! Form::label('product', $product->longName) !!}
           {!! Form::hidden('nameEn[$i]', $product->nameEn) !!}
           {!! Form::hidden('orderNum[$i]', $orderNum) !!}
           {!! Form::hidden('price[$i]', $product->price) !!}
           {!! Form::text('qty[$i]',Input::old("qty.$i"), ['class' => 'form-control']) !!}
@endforeach

Thank you for the reply. It did not worked that way but it works with:

@foreach ($products as $i => $product)
            {!! Form::label('product', $product->longName) !!}
            {!! Form::hidden('nameEn[]', $product->nameEn) !!}
            {!! Form::hidden('orderNum[]', $orderNum) !!}
            {!! Form::hidden('price[]', $product->price) !!}
            {!! Form::text('qty[]',Input::old('qty'), ['class' => 'form-control']) !!}
@endforeach

Now my problem is how to sotre that array in the database. What do you think, do I have to open another thread for this and mark this as solved or I can expect the reply here.

Thanks!

Last updated 8 years ago.
0

Because 'qty[$i]' is a string literal with no interpolation. "qty[$i]" would evaluate the variable inside the string.

0

lagbox said:

Because 'qty[$i]' is a string literal with no interpolation. "qty[$i]" would evaluate the variable inside the string.

Thanks for pointing that out. Of course you are right, I was writing that in a hurry - mea culpa.

I have updated my reply with double quotes.

@Lameboy - IMHO, a new question better fits into a new thread, for this would make it searchable for other people having the same issue.

Last updated 8 years ago.
0

if you don't want to search things in db you can serialize arrays and store it as a string in db.

0

Thank you, guys! I'm mark this as solved!

0

Sign in to participate in this thread!

Eventy

Your banner here too?

LameBoy lameboy Joined 22 Mar 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.