jhutto
3071
3
General

Creating simple dropdown from database - Laravel Collective Form

Posted 11 months ago by jhutto

I'm new to laravel and just trying to stay up to speed with the different versions. Using Laravel 5.6

I have created blade form and have been able to create my dropdown from the database,, but I keep running into forum questions showing selects using the Collective Form sytle. But I can't find anything in the documentation about the arguments for the {{ Form::Select ( arg1, arg2, arg3, arg4)}} ....... or how to create it from a database table.

So, I need help in writing this {{Form::Select }} statement that does the same thing as below.

Create Form ... Select looping through and creating the dropdown. Works good. Controller just pulls the list from database and passes it to the form as $instructors

<div class="form-group col-md-6">
                                                <label for="title">Instructor:</label>
                                                    <select name="Instructorid" id="Instructorid" class="form-control" style="width:350px;margin-left:50px;">
                                                        <option value="">--- Select Instuctor ---</option>
                                                        @foreach ($instructors as $instructor)
                                                            <option value="{{ $instructor->id }}">{{ $instructor->FirstName }} {{ $instructor->LastName }}"</option>">
                                                        @endforeach
                                                    </select>
                                                </label>
 </div>
``


How do I create the same loop in the {{ Form::select('Instructors', $instructors, ....) }} 
format?





Please sign in or create an account to participate in this conversation.