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.
Twill
Multi Select – Twill
Twill — An open source CMS toolkit for Laravel
2 Replies
bmasquio
bmasquioOP2y ago
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]; }) ); }
Want results from more Discord servers?
Add your server