Hi, my name is David Carr and I'm a PHP Developer.

Blog Archives Categories Authors About Me Open Source Books Contact Me

Sponsor Me

Help support the blog so that I can continue creating new content!

My Latest Book

Laravel: The Modular way

Learn how to build modular applications with Laravel Find out more


create a select menu set the name and placeholder for the initial option

<x-form.select name='types' placeholder='Select'>


Leave off the placeholder to have only the select and options that can be selected

<x-form.select name='types'>


In order to set the option, an array is needed and is looped over and then a nested component is used.

Pass in the key and value from the array

$options = [1 => 'one', 2 => 'two', 3 => 'three'];

<x-form.select name='types' placeholder='Select'>
    @foreach($options as $key => $value)
        <x-form.selectoption key='{{ $key }}' value='{{ $value }}'></x-form.selectoption>

Copyright © 2009 - 2022 David Carr. All code MIT license. All rights reserved.