Checkboxlist selecting all options

I have a simple CheckboxList, but when I click in one option, it selects or deselects all of them. The only difference of that checkboxlist is that it is in a resource from another panel (my "client" panel, which is not the default "admin" one) * other fields in the same form works as they should.
CheckboxList::make('technologies')
->options([
'tailwind' => 'Tailwind CSS',
'alpine' => 'Alpine.js',
'laravel' => 'Laravel',
'livewire' => 'Laravel Livewire',
])
CheckboxList::make('technologies')
->options([
'tailwind' => 'Tailwind CSS',
'alpine' => 'Alpine.js',
'laravel' => 'Laravel',
'livewire' => 'Laravel Livewire',
])
Solution:
found the problem... In my CreateBooking I have a fillForm : ```php...
Jump to solution
4 Replies
LeandroFerreira
LeandroFerreira4mo ago
Custom livewire component? Share the code..
Bruno Silva
Bruno SilvaOP4mo ago
No, standard resource, but in a different panel
class BookingResource extends Resource
{
protected static ?string $model = Booking::class;

protected static ?string $modelLabel = 'Reserva';

protected static ?string $navigationLabel = 'Minhas Reservas';

protected static ?string $navigationIcon = AppIcons::Calendar->value;

public static function form(Form $form): Form
{
return $form
->schema([
CheckboxList::make('technologies')
->options([
'tailwind' => 'Tailwind CSS',
'alpine' => 'Alpine.js',
'laravel' => 'Laravel',
'livewire' => 'Laravel Livewire',
]),
]);
}

public static function table(Table $table): Table
{
return BookingTable::table($table);
}

public static function getPages(): array
{
return [
'index' => Pages\ListBookings::route('/'),
'create' => Pages\CreateBooking::route('/create'),
'edit' => Pages\EditBooking::route('/{record}/edit'),
];
}
}
class BookingResource extends Resource
{
protected static ?string $model = Booking::class;

protected static ?string $modelLabel = 'Reserva';

protected static ?string $navigationLabel = 'Minhas Reservas';

protected static ?string $navigationIcon = AppIcons::Calendar->value;

public static function form(Form $form): Form
{
return $form
->schema([
CheckboxList::make('technologies')
->options([
'tailwind' => 'Tailwind CSS',
'alpine' => 'Alpine.js',
'laravel' => 'Laravel',
'livewire' => 'Laravel Livewire',
]),
]);
}

public static function table(Table $table): Table
{
return BookingTable::table($table);
}

public static function getPages(): array
{
return [
'index' => Pages\ListBookings::route('/'),
'create' => Pages\CreateBooking::route('/create'),
'edit' => Pages\EditBooking::route('/{record}/edit'),
];
}
}
odd, I've created a project from scratch just to create two panels and test that, but it worked normally... I'll continue investigating
LeandroFerreira
LeandroFerreira4mo ago
hum..
Solution
Bruno Silva
Bruno Silva4mo ago
found the problem... In my CreateBooking I have a fillForm :
protected function fillForm(): void
{
$data = request()->first_booking_data;

if ($data) {
$this->form->fill($data);
}
}
protected function fillForm(): void
{
$data = request()->first_booking_data;

if ($data) {
$this->form->fill($data);
}
}
I did that so the client can fill a form without logging in. Then it would send that data to this resource to automatically fill that form after the client registers. Adding this line at the end seems to have worked: $this->form->fill(); but I'm trying to improve this code. It doesn't feel like the right way to do it. anyway, thanks for the help!
Want results from more Discord servers?
Add your server