Select->multiple() in SelectColumn?

Hi all, Would like to have a select "multiple" as SelectColumn. Doesn't seem to be possible yet out of the box right? How should I approach this? Custom column?
7 Replies
Dennis Koch
Dennis Koch2mo ago
Yeah, you could extend the default column or try a PR to make this possible.
Dhru
Dhru2mo ago
Depending on your use case look into BulkActions perhaps
Giant Robo
Giant Robo2mo ago
you can write a CustomColumn, I was looking at doing the exact same thing, ended up putting the form into a ->slideover() message me if you can solve this
Mike Peters
Mike PetersOP2mo ago
Will give it a go! yes having a slideover right now, but for the users it's one click too many 😅
Mike Peters
Mike PetersOP2mo ago
@Dennis Koch @Dhru @Giant Robo managed it adding a separate Form to the Livewire component that currently has the table. The table cell that should have the select multiple now has a custom view to render the specific form field matching the row
ViewColumn::make('type')
->label('type')
->view('etc.etc..form-column', [
'field' => 'type',
])
ViewColumn::make('type')
->label('type')
->view('etc.etc..form-column', [
'field' => 'type',
])
form-column view reused for multiple fields:
<div wire:key="{{ $this->getId() }}.table.{{ $recordKey }}.{{$field}}" class="px-2 py-4 w-full">
{{ $this->form->getComponent('formData.channels.'. $recordKey .'.'. $field) }}
</div>
<div wire:key="{{ $this->getId() }}.table.{{ $recordKey }}.{{$field}}" class="px-2 py-4 w-full">
{{ $this->form->getComponent('formData.channels.'. $recordKey .'.'. $field) }}
</div>
No description
Mike Peters
Mike PetersOP2mo ago
This solution does need the following for the livewire component:
public function mount(): void
{
$this->form->fill([
'channels' => ...->toArray(),
]);
}
public function mount(): void
{
$this->form->fill([
'channels' => ...->toArray(),
]);
}
and I added a custom save action below the table as the user wants to save all changes together and not "live" There you can then just do $this->form->getState() If you want to know more about the solution / something is not clear, let me know, I'll post some more details
Dhru
Dhru2mo ago
Nicely done! Thanks for sharing the update

Did you find this page helpful?