Support the ongoing development of Laravel.io →
Blade Forms

I am getting an array of products from my database and need to know how to list them in a drop down in a form within my blade file.

Currently, the array I'm using looks like this:

$products = [
{
id:1,
name:product_1,
qty:5,
price:3.99
},
{
id:2,
name:product_2,
qty:5,
price:5.99
}
{
id:3,
name:product_3,
qty:20,
price:10.99
}
{
id:4,
name:product_4,
qty:10,
price:3.99
}
]

and my form tags lok like this

{!! Form::select('product', $products); !!}

How can i get it to only display the name from the object and also when i submit to using the ID in stead of the drop down index.

If you need any more info i am happy to supply it :)

Thanks in advance.

Last updated 3 years ago.
0

$products - must be collection then

{!! Form::select('product', $products->pluck('name','id')) !!}
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.

© 2025 Laravel.io - All rights reserved.