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
18.1k stars 2.83k forks source link

When checkboxlist or select options with Enum :int in form could not be remove. #8423

Closed wxfjamdc closed 1 year ago

wxfjamdc commented 1 year ago

Package

filament/forms

Package Version

v3.0.47

Laravel Version

v10

Livewire Version

v3.0.2

PHP Version

PHP 8.1

Problem description

I used bitwise assignment on an int field and then created an enum class for this field.

Pass in the enumeration class in the option of the form's checkboxlist or select field.

The form can be created normally, but when modified, if you try to delete items in the checkboxlist or select, a type error will be prompted.

App\Enums\UserTypeEnum::from(): Argument #1 ($value) must be of type int, string given

Expected behavior

Livewire does not pass the "rm " value when modifying, or it can receive parameters normally.

Steps to reproduce

image

image

Reproduction repository

https://github.com/wxfjamdc/filamentphp_form_with_enum

Relevant log output

No response

danharrin commented 1 year ago

If you could help us by attempting a PR, that would be great!

ilpav12 commented 1 year ago

This is issue has been also mention here https://github.com/livewire/livewire/discussions/6801 on livewire repository

zepfietje commented 1 year ago

So this is a Livewire issue? If so, someone should attempt a failing test PR to the Livewire repo. Otherwise it won't be fixed there.

ilpav12 commented 1 year ago

I don't know if it fixable from filament because the issue is how Livewire send updates. As can be seen in the livewire discussion the body is something like this:

{
    "_token": "avu27UX1G0fNux3D1QGpH2XPAU1ofsdlMF6J3QfL",
    "components": [
        {
            "snapshot": "{...},\"checksum\":\"...\"}",
            "updates": {
                "note.topics.1": "__rm__"
            },
            "calls": []
        }
    ]
}

The Enum value is set to "__rm__" that triggers a wrong type exception. I don't know it this behavior can be override.

zepfietje commented 1 year ago

Okay, I'm going to close this as a Livewire issue then. Unless @danharrin wants to keep it open for tracking.

johanmolen commented 9 months ago

Sorry for the late comment here, but does anyone know if this is getting fixed in Livewire? It does affect multiple Filament projects of mine.