Last Updated: September 09, 2019
·
2.206K
· byjml

Laravel: How to pass database values to the form-builder dropdown

I use this in the controller file:

$languages = Language::lists('language_name', 'id');

$this->layout->content = View::make('content.create', compact('languages'));

...and in the view file:

{{ Form::select('language', $languages) }}

...and that, ladies and gentlemen, should work.

2 Responses
Add your response

Where in the controller will I put the code and in what controller?

over 1 year ago ·

Hi @itspecialist,

Depends on your controller. It's usually inside the method you use to display form views, e.g. create() or edit() methods of your resourceful controllers.

over 1 year ago ·