Skip to content

Checkboxes in a table #336

Closed
Closed
@brouwersron

Description

I have a table that loops over some items, and I want to have some checkboxes to perform some bulk actions:

@foreach($items as $item)
<flux:row>
    <flux:cell>
        <flux:checkbox wire:model="selectedItems" value="{{ $item->id }}"/>
    </flux:cell>
</flux:row>
@endforeach

The above does not work, the below however, does work:

@foreach($items as $item)
<flux:row>
    <flux:cell>
        <input type="checkbox" wire:model="selectedItems" value="{{ $item->id }}"/>
    </flux:cell>
</flux:row>
@endforeach

I have a button somewhere:

<flux:button wire:click="bulk">Bulk actions</flux:button>

And in my component:

    public $selectedItems = [];

    public function bulk()
    {
        dd($this->selectedItems); // With the flux checkboxes this shows "true" instead of an array of selected id's
    }

Why doesn't this work with Flux checkboxes? Am I missing something? I cannot put these checkboxes inside a <flux:checkbox.group>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions