You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can use the Filament Repeater field to create more complex data structures based on a array of objects.
Actual Behaviour:
When I create a custom attribute field using the Filament Repeater field, which extends from the Lunar List field, it doesn't render existing data and throws this error:
Filament\Forms\ComponentContainer::getRawState(): Return value must be of type Illuminate\Contracts\Support\Arrayable|array, stdClass returned
Steps To Reproduce:
Create a new field:
<?phpnamespaceApp\Domain\Lunar\Fields;
useLunar\FieldTypes\ListField;
class ProductDimensionsField extends ListField {}
Create a field type:
<?phpnamespaceApp\Domain\Lunar\FieldTypes;
useApp\Domain\Lunar\Synthesizers\ProductDimensionsFieldSynth;
useFilament\Forms\Components\Component;
useFilament\Forms\Components\Repeater;
useFilament\Forms\Components\TextInput;
useLunar\Admin\Support\FieldTypes\ListField;
useLunar\Models\Attribute;
class ProductDimensionsFieldType extends ListField
{
/** * Specify the Synthesizer for this field type */protectedstaticstring$synthesizer = ProductDimensionsFieldSynth::class;
/** * Define the Filament component for rendering */publicstaticfunctiongetFilamentComponent(Attribute$attribute): Component
{
return Repeater::make($attribute->handle)
->collapsed()
->itemLabel(fn (array$state): ?string => self::getLabel($state))
->columns(3)
->schema([
TextInput::make('length')
->numeric()
->label('Length')
->required(),
TextInput::make('depth')
->numeric()
->label('Depth')
->required(),
TextInput::make('height')
->numeric()
->label('Height')
->required(),
TextInput::make('label')
->label('Label')
->required(),
])
->addable()
->deletable()
->reorderable();
}
/** * Get the label for the repeater item */protectedstaticfunctiongetLabel(array$state): ?string
{
returnsprintf(
'%s | Price: %s - Updated: %s',
$state['label'],
$state['price_formatted'] ?? 'N/A',
$state['elfsquad_update_timestamp'] ?? 'N/A'
);
}
}
Create a Livewire Synthesizer
<?phpnamespaceApp\Domain\Lunar\Synthesizers;
useApp\Domain\Lunar\Fields\ProductDimensionsField;
useLunar\Admin\Support\Synthesizers\ListSynth;
class ProductDimensionsFieldSynth extends ListSynth
{
/** * Unique key for the synthesizer */publicstatic$key = 'lunar_dimensions_field';
protectedstatic$targetClass = ProductDimensionsField::class;
}
tdwesten
changed the title
How to implement a Filament Repeater as attribute field
Can not implement a Filament Repeater as attribute field
Jan 21, 2025
Expected Behaviour:
I can use the Filament Repeater field to create more complex data structures based on a array of objects.
Actual Behaviour:
When I create a custom attribute field using the Filament Repeater field, which extends from the Lunar List field, it doesn't render existing data and throws this error:
Steps To Reproduce:
And register it field in your service provider.
AttributeData::registerFieldType(ProductDimensionsField::class, ProductDimensionsFieldType::class);
The text was updated successfully, but these errors were encountered: