F
Filament2y ago
dyo

CheckboxList bulkToggleable is not working

I have these CheckboxList line of code
CheckboxList::make('setoran_id')->dehydrated(false)->label('Data Setoran')
->columnSpanFull()->hidden(fn ($get) => $get('pilih_semua') == true)
->options(function ($get, $livewire) {
$type = ($livewire->ownerRecord->type == 'Pemasukan')
? ["CR", "Pindah Buku"] : ["DB"];

$options = array();
if ($get('periode_awal') && $get('periode_akhir')) {
$setoran = Setoran::whereDate('tanggal', '>=', $get('periode_awal'))
->whereDate('tanggal', '<', $get('periode_akhir'))
->whereIn('type', $type)->where('sudah_dibukukan', 0)
->where('rekening_id', $get('rekening_id'))->get();

foreach ($setoran as $value) {
$options[$value->id] = $value->id . ' - '
. number_format($value->dana) . ' - '
. $value->keterangan;
}

if ($setoran->count()) {
return $options;
} else $options = ([0 => 'Tidak ada data transaksi']);
}
})->columns(2)->bulkToggleable()
CheckboxList::make('setoran_id')->dehydrated(false)->label('Data Setoran')
->columnSpanFull()->hidden(fn ($get) => $get('pilih_semua') == true)
->options(function ($get, $livewire) {
$type = ($livewire->ownerRecord->type == 'Pemasukan')
? ["CR", "Pindah Buku"] : ["DB"];

$options = array();
if ($get('periode_awal') && $get('periode_akhir')) {
$setoran = Setoran::whereDate('tanggal', '>=', $get('periode_awal'))
->whereDate('tanggal', '<', $get('periode_akhir'))
->whereIn('type', $type)->where('sudah_dibukukan', 0)
->where('rekening_id', $get('rekening_id'))->get();

foreach ($setoran as $value) {
$options[$value->id] = $value->id . ' - '
. number_format($value->dana) . ' - '
. $value->keterangan;
}

if ($setoran->count()) {
return $options;
} else $options = ([0 => 'Tidak ada data transaksi']);
}
})->columns(2)->bulkToggleable()
but the bulkToggleable is not working properly. when i click select all, it doesnt work, the same with unselect all. where did i do wrong?
5 Replies
dyo
dyoOP2y ago
can anyone help me?
Patrick Boivin
Any errors in the browser console?
dyo
dyoOP2y ago
nothing is shown btw, i'm using the attribute in form modal.. after I've done some research, the bulkToggleable() is not working only in my case below
php
CheckboxList::make('setoran_id')->label('Data Setoran')
->columnSpanFull()->options(function ($get, $livewire) {
$type = ($livewire->ownerRecord->type == 'Pemasukan')
? ["CR", "Pindah Buku"] : ["DB"];

$options = array();
if ($get('periode_awal') && $get('periode_akhir')) {
$setoran = Setoran::whereDate('tanggal', '>=', $get('periode_awal'))
->whereDate('tanggal', '<', $get('periode_akhir'))
->whereIn('type', $type)->where('sudah_dibukukan', 0)
->where('rekening_id', $get('rekening_id'))->get();

foreach ($setoran as $value) {
$options[$value->id] = $value->id . ' - '
. number_format($value->dana) . ' - '
. $value->keterangan;
}

if ($setoran->count()) {
// dd($options);
return $options;
} else return $options = ([0 => 'Tidak ada data transaksi']);
}
})->columns(2)->bulkToggleable()
php
CheckboxList::make('setoran_id')->label('Data Setoran')
->columnSpanFull()->options(function ($get, $livewire) {
$type = ($livewire->ownerRecord->type == 'Pemasukan')
? ["CR", "Pindah Buku"] : ["DB"];

$options = array();
if ($get('periode_awal') && $get('periode_akhir')) {
$setoran = Setoran::whereDate('tanggal', '>=', $get('periode_awal'))
->whereDate('tanggal', '<', $get('periode_akhir'))
->whereIn('type', $type)->where('sudah_dibukukan', 0)
->where('rekening_id', $get('rekening_id'))->get();

foreach ($setoran as $value) {
$options[$value->id] = $value->id . ' - '
. number_format($value->dana) . ' - '
. $value->keterangan;
}

if ($setoran->count()) {
// dd($options);
return $options;
} else return $options = ([0 => 'Tidak ada data transaksi']);
}
})->columns(2)->bulkToggleable()
when i created a new CheckboxList in the same form with Toggleable and with simple options, something like options([1=>1, 2=>2]), the toggle is working fine.. can anyone show me what is wrong?
awcodes
awcodes2y ago
Your if / else isn’t valid syntax.
dyo
dyoOP2y ago
what it should be?

Did you find this page helpful?