Laravel - Form Input - Multiple select for a one to many relationship

后端 未结 7 930
情深已故
情深已故 2021-02-01 04:40

One of the requirements in an application that I am building is for a form input which takes in a varying number of items for a single field. For instance, sports that I play ar

7条回答
  •  青春惊慌失措
    2021-02-01 04:45

    I agree with user3158900, and I only differ slightly in the way I use it:

    {{Form::label('sports', 'Sports')}}
    {{Form::select('sports',$aSports,null,array('multiple'=>'multiple','name'=>'sports[]'))}}
    

    However, in my experience the 3rd parameter of the select is a string only, so for repopulating data for a multi-select I have had to do something like this:

    
    

提交回复
热议问题