Setting selected option in laravel form

后端 未结 14 988
春和景丽
春和景丽 2020-12-25 14:09

I need to give selected value like this html:


                        
    
提交评论

  • 2020-12-25 14:40

    To echo some other answers here, the code I just used with 5.6 is this

    {{ Form::select('status', ['Draft' => 'Draft', 'Sent' => 'Sent', 'Paid' => 'Paid'], $model->status, ['id' => 'status']) }}
    

    In order to be able to use the Form Helper from LaravelCollective I took a look at https://laravelcollective.com/docs/master/html#drop-down-lists

    I also had to composer require the dependency also so that I could use it in my projects

    composer require "laravelcollective/html":"^5"
    

    Lastly I altered my config/app.php and added the following in the $aliases array

        'Form' => Collective\Html\FormFacade::class,
    

    https://laravelcollective.com/docs/master/html should be consulted if any of the above ceases to work.

    0 讨论(0)
  • 提交回复
    热议问题