multi select selected options
I'm using the multi select as documented in https://twill.io/docs/form-fields/multi-select.html#multi-select, but I can't find a way to mark options as selected by default.
2 Replies
Got it. I created a model accessor. The problem was that it was not returning the collection as expected. I discovered it would use the array item with the key 'id'. So I had to adapt the accessor, as my 'getRoles' function would return an array of strings.
protected function observatoryRoles(): Attribute
{
return Attribute::make(
get: fn() => $this->getRoles()->map(function ($item) {
return ['id' => $item];
})
);
}
How I implemented this?
https://discord.com/channels/811936425858695198/1207262433161379870