Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Laravel: Using form::select with <optgroup>
<?php
//Source: http://forums.laravel.com/viewtopic.php?id=2807
Route::get('optgroup', function()
{
$eat_options = array(
'animals' => array(
'cats',
'dogs',
'monkeys',
),
'robots' => array(
'bender',
'johnny 5',
'metal gear',
),
);
echo Form::select( 'thing_to_eat', $eat_options, Input::old( 'thing_to_eat' ));
});
?>
@tucq88

This comment has been minimized.

Copy link

commented Feb 6, 2015

Worked with Laravel 4.2

@kraudy

This comment has been minimized.

Copy link

commented Sep 27, 2016

it works with laravel 5.3, i had the same issue but i used [ ] instead of array()

@vrkansagara

This comment has been minimized.

Copy link

commented Nov 10, 2016

Perfect 💯 works with laravel 5.3*

@RicardoCruz6395

This comment has been minimized.

Copy link

commented Nov 27, 2017

Worked with Laravel 5.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.