Skip to content

Instantly share code, notes, and snippets.

@sineld
Created October 2, 2012 09:12
Show Gist options
  • Save sineld/3817657 to your computer and use it in GitHub Desktop.
Save sineld/3817657 to your computer and use it in GitHub Desktop.
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' ));
});
?>
@kraudy
Copy link

kraudy commented Sep 27, 2016

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

@vrkansagara
Copy link

Perfect 💯 works with laravel 5.3*

@RicardoCruz6395
Copy link

Worked with Laravel 5.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment