Tony
Tony
FFilament
Created by Tony on 2/10/2024 in #❓┊help
Header action button not refreshing
I have a header action that has a conditional color() and action() it looks like this: ->color(fn () => $this->user->is_tracking ? Color::Orange : Color::Green) ->action(fn () => $this->user->is_tracking ? $this->user->stopTracking() : $this->user->startTracking()) The stopTracking() and startTracking() function toggle the $this->user->is_tracking variable The problem is that for some reason, the button doesnt refresh (change color) the first time i press it. It executes the action without problems, but the color doesnt change, i have to press it twice, then it changes to orange. its pretty weird, any help would be apreciated
3 replies
FFilament
Created by Tony on 4/21/2023 in #❓┊help
Problem with two select fields using same relationship
I have a polymorphic relationship of filters, Filters have a column describing its type, lets say A and B I want 2 select fields on related model forms, using the third parameter of the relationship() method, i scope the results to one kind (A) or another (B) Example:
Select::make('a')
->label('A')
->multiple()
->searchable()
->relationship('filters', 'name', fn (Builder $query) => $query->where('type', 'a')),
Select::make('b')
->label('B')
->multiple()
->searchable()
->relationship('filters', 'name', fn (Builder $query) => $query->where('type', 'b'))
Select::make('a')
->label('A')
->multiple()
->searchable()
->relationship('filters', 'name', fn (Builder $query) => $query->where('type', 'a')),
Select::make('b')
->label('B')
->multiple()
->searchable()
->relationship('filters', 'name', fn (Builder $query) => $query->where('type', 'b'))
The problem is that the last field on the form for the same relationship, in this case "b" is overwriting the value from the "a" select, i would need it to just add its values to the relationship, but not overwriting it, because of this problem, the only usable select field is the last one in the form, which has scoped values to only show one of the kinds of filters I want to separate the two kinds of filters in different select fields, i know that if i only used one field and didn't scope the options, it would work, but i want to know if there is any way to do it 👀
42 replies