F
Filament17mo 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
dyoOP17mo ago
can anyone help me?
Patrick Boivin
Patrick Boivin17mo ago
Any errors in the browser console?
dyo
dyoOP16mo 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
awcodes16mo ago
Your if / else isn’t valid syntax.
dyo
dyoOP16mo ago
what it should be?
Want results from more Discord servers?
Add your server