filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
17.65k stars 2.76k forks source link

CheckboxList not working when using statePath #11507

Closed ernoferrari closed 6 months ago

ernoferrari commented 6 months ago

Package

filament/filament

Package Version

v3.2.35

Laravel Version

v10.45.0

Livewire Version

v3.4.6

PHP Version

8.2.1

Problem description

I have a custom page with form and I have set a statePath. ChecboxList works like a single checkbox field. But if I remove the statePath call, then it works right.

Expected behavior

CheckboxList should set state as array with selected options but now it just set the value to true.

Steps to reproduce

Add statePath to your form and add CheckboxList component, like here: https://github.com/ernoferrari/filament-checkboxlist-issue/blob/main/app/Filament/Pages/IssuePage.php

Reproduction repository

https://github.com/ernoferrari/filament-checkboxlist-issue

Relevant log output

No response

zepfietje commented 6 months ago

Make sure to fill the form as per the docs: https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component#adding-the-form.

MShJSTM commented 1 month ago

I have the same problem .

ernoferrari commented 1 month ago

@MShJSTM Just add this code to the page and it should work:

public function mount(): void { $this->form->fill(); }