Watoka
Watoka
FFilament
Created by Watoka on 12/8/2023 in #❓┊help
Spatie tags filter
I am using Spatie tags in a resource, but if I am making a filter, it lists the available tags as {"en":"MyTag"}. Here's the code:
SelectFilter::make('tags')
->label('Tags')
->multiple()
->preload()
->forceSearchCaseInsensitive()
->relationship('tags', 'name'),
SelectFilter::make('tags')
->label('Tags')
->multiple()
->preload()
->forceSearchCaseInsensitive()
->relationship('tags', 'name'),
This was working fine in Filament v2. Probably there is a simple solution for this, but I could not figure it out.
38 replies
FFilament
Created by Watoka on 12/6/2023 in #❓┊help
tag
Refresh resource form data form action I have a form in a resource where I am populating a relationship repeater from a section header action. After the relationship is populated, I need to refresh the repeater to show the newly populated data, but I cannot use the $this->refreshFormData() method because I am in a static class. Probably there is a workaround for this. My simplified code:
Forms\Components\Section::make('Client Rates')
->live()
->headerActions([
Action::make('add_group_preset')
->label('Add Group Preset')
->requiresConfirmation()
->form([
Forms\Components\Select::make('group_id')
->label('Author')
->options(ServiceGroup::query()->isActive()->pluck('name', 'id'))
->required(),
])
->action(function (array $data, $record, $livewire) {

// Add service items
//...
// refresh service items after adding a group preset
$this->refreshFormData(['serviceItems']);
}),
])
->schema([
TableRepeater::make('serviceItems')
//->headers(['Service Items', 'Default Rate'])
->relationship()
->live()
//...
->schema([
Forms\Components\Select::make('service_item_id')
->label('Service Item')
->relationship('serviceItem', 'name',
fn(Builder $query) =>
$query->where('active', 1)
->where('category', 'visit'))
->preload()
->distinct()
->live(),
Forms\Components\TextInput::make('default_rate')
->label('Default Rate'),

])
]),
Forms\Components\Section::make('Client Rates')
->live()
->headerActions([
Action::make('add_group_preset')
->label('Add Group Preset')
->requiresConfirmation()
->form([
Forms\Components\Select::make('group_id')
->label('Author')
->options(ServiceGroup::query()->isActive()->pluck('name', 'id'))
->required(),
])
->action(function (array $data, $record, $livewire) {

// Add service items
//...
// refresh service items after adding a group preset
$this->refreshFormData(['serviceItems']);
}),
])
->schema([
TableRepeater::make('serviceItems')
//->headers(['Service Items', 'Default Rate'])
->relationship()
->live()
//...
->schema([
Forms\Components\Select::make('service_item_id')
->label('Service Item')
->relationship('serviceItem', 'name',
fn(Builder $query) =>
$query->where('active', 1)
->where('category', 'visit'))
->preload()
->distinct()
->live(),
Forms\Components\TextInput::make('default_rate')
->label('Default Rate'),

])
]),
3 replies