OK, so the problem was somewhere in $attributes property but funny thing was it appeared only when #[Modelable] attribute was present. Anyway, removing $attributes fixed my issue.
Problem with #[Modelable] in livewire component in FIlament form
I managed to create custom Filament form component used in an event registraion form. User can pick weekdays (monday, tuesday ...) , each with separate checkbox.
My custom field class is simple, it just sets correct view:
<?php
namespace App\Filament\Forms\Components;
use Filament\Forms\Components\Field;
class Weekdays extends Field
{
protected string $view = 'filament.forms.components.weekdays';
}
Inside view, I want to use custom Livewire component weekdays picker:
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
<livewire:weekdays-picker wire:model="{{ $getStatePath() }}" />
</x-dynamic-component>
This is Livewire component class:
<?php
namespace App\Livewire;
use Livewire\Component;
use Livewire\Features\SupportAttributes\AttributeCollection;
use Livewire\Attributes\Modelable;
class WeekdaysPicker extends Component
{
public AttributeCollection $attributes;
#[Modelable]
public $value = '';
// ... other properties ...
public function render()
{
return view('livewire.weekdays-picker');
}
// ... other methods ...
}
I have problem with #[Modelable] attribute in this component. Without it, it displays (of course without any value), but whenever I add it I get an error:
Property type not supported in Livewire for property: [{}]
Whatever I do, I cannot get rid of it. Am I missing something? Or is there something I can simplify? This is my first custom form component in Filament...
Note: When I place <input type="text" wire:model="{{ $getStatePath() }}" /> in weekdays.blade.php, It renders with value correctly bind.
Please or to participate in this conversation.