Created
January 9, 2015 12:25
-
-
Save timersys/948088de7187dcf8c31a to your computer and use it in GitHub Desktop.
Laravel pass model to create dropdown in views
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * IF you have a States model and you want to create a simple dropdown in your views you can pass the array very easily doing: | |
| **/ | |
| public function create() | |
| { | |
| // first parameter is option label and second the option value | |
| $states = State::lists('state', 'id'); | |
| return View::make('anuncios.create', compact('states')); | |
| } | |
| /** | |
| * Then in your view simple | |
| */ | |
| {{ Form::select('state', $states , ['class' => 'form-control choosen-select']) }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment