Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

IslandMan's avatar

Drop down list in laravel booking form

I have been working to build a laravel form and for the fields where text input is required I have successfully created. The following part works.

1 Personal Information

{{ $errors->first('name') }}

{{ $errors->first('email') }}

{{ $errors->first('phone') }} However, I want to make a drop down list of countries (and after this two or three other drop down lists). This is the HTML part of it. How do I use a drop down list in Laravel where the selected country will appear in the email I receive after the user submits the form?

Nationality: * Afghanistan Albania Algeria (includes all the countries in the list)

I want to include this as a drop down and the selected item must appear on the email I get from the user. Is there any way to code this part without using the Laravel Collective HTML?

0 likes
2 replies
ftiersch's avatar
ftiersch
Best Answer
Level 28

Sure, the Laravel Collective doesn't do any magic. You just have to program the logic yourself :)

You basically create a foreach loop for your countries like that:

<select name="country">
    @foreach ($countries as $country)
        <option value="{{ $country }}" @if(old('country', 'default country') == $country) selected="selected" @endif>{{ $country }}</option>
    @endforeach
</select>
1 like
IslandMan's avatar

Ive got the following error message. I guess I have to use the list of countries. How could I do that? Please help.

ErrorException (E_ERROR) Undefined variable: countries (View: C:\xampp\htdocs\lsapp\resources\views\contact\create.blade.php) Previous exceptions Undefined variable: countries (0)

Please or to participate in this conversation.