3
votes

I've got a string value from a controller which is:

$pickedValues = "1,2";

So what I'm trying to do is set the multiple selected values on the view, here is the select code that I have right now:

{{Form::select("selection[]", $data, (isset($pickedValues)) ? array($pickedValues) : '',
        [
            "class"    => "multiple-select",
            "multiple",
        ])
}}

That problem that I'm getting right now that it is not displaying the selected options, but if I put the values manually like array(1,2) it works. I've tried setting it as array((int)$pickedValues) but it only displays the value 1.

1
Maybe you can use explode(',' $pickedValues) instead of array($pickedValues)... - kiske
I've tried that but the selected values still doesn't appear. - user3235016
Did you correct my misspelled? explode(',', $pickedValues), I forgot the comma... - kiske
Yeah thats what the first thing I did before doing (int). - user3235016

1 Answers

1
votes

I found a solution to this problem, Try the value like this

array('1','2')