Default field to select in illuminate / html

0

I have a problem and I have already searched the internet for the solution. No success!

I have a form and inside it, a select filled in automatically:

{!! Form::select('categoria_id', $categorias, null, ['class' => 'form-control']) !!}

Okay, it works. But I need to create an option with empty value . Type: " Select an option ", therein lies the problem. I've tried several forms, but what I found was for another version of Laravel and nothing was done.

    
asked by anonymous 23.07.2015 / 20:53

1 answer

2

This issue was recently solved in the Laravel Collective .

{!! Form::select('size', ['dados' => 'no', 'seu' => 'select'], null, ['placeholder' => 'Selecione uma opção']) !!}

If you are not using it in your application, I recommend using it.

The Form component has been removed from the Laravel core since version 5, as you can see in the documentation .

  

If you are using Form or HTML helpers, you will see an error stating class 'Form' not found or class 'Html' not found . The Form and HTML helpers have been deprecated in Laravel 5.0; however, there are community-driven replacements such as those maintained by the Laravel Collective .

Make sure your composer.json is using laravelcollective/html . If you do not follow the installation step by step .

    
23.07.2015 / 20:58