3

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.

user3235016
  • 317
  • 2
  • 11

1 Answers1

1

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

array('1','2')
  • This is not dynamic. It's very likely that the string "1,2" get other contents like "9,27,2". So this isn't a good answer. – UfguFugullu Apr 22 '20 at 13:32