E
E
Evgeny Perin2015-05-13 10:15:29
Laravel
Evgeny Perin, 2015-05-13 10:15:29

How to compose select tag in laravel 5 form?

I'm confused about something, I just can't figure it out, help me with a kick in the right direction ...
There is a User model, the table has a role column - enum('admin', 'member') , member by default.
These are user roles, member by default.
I am making a page for editing users, and there in the select tag I need to make a drop-down list with roles. To default to the current role.

{!! Form::select('role', ['', 'admin', 'member'], null , ['class' => 'form-control']) !!}

Now it's done like this. When editing, the select field is initially empty, and a list of roles is displayed. And the roles are driven in manually. Can you kick in the right direction, how to set the default value of the current role, and how to list the roles without manually specifying, but to have it list all the unique possible roles?
Thanks :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tesla, 2015-05-14
@seoperin

Form::selectIt 's obvious in the code

public function select($name, $list = array(), $selected = null, $options = array())

nullPaste in your current role id instead .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question