w5m
w5m
FFilament
Created by w5m on 10/4/2024 in #❓┊help
How to get all options from table filter in table header action?
I've finally managed to get hold of the list of Select options. I had to modify the creation of the project_id Select component slightly by adding ->key('project') . Then, in the header action, the following code gave me an array of the options...
Tables\Actions\Action::make('next-project')
->action(function (\Livewire\Component $livewire): string {
$filters = $livewire->getTable()->getFilters();
$filter = $filters['client_project'];
dd($filter->getForm()->getComponent('project')->getOptions());
})
Tables\Actions\Action::make('next-project')
->action(function (\Livewire\Component $livewire): string {
$filters = $livewire->getTable()->getFilters();
$filter = $filters['client_project'];
dd($filter->getForm()->getComponent('project')->getOptions());
})
10 replies
FFilament
Created by w5m on 10/4/2024 in #❓┊help
How to get all options from table filter in table header action?
Select::make('project_id')
->relationship('project', 'number', modifyQueryUsing: function (Builder $query, Get $get) {
return $query
->where('client_id', $get('client_id'))
->orderBy('number', 'desc');
})
Select::make('project_id')
->relationship('project', 'number', modifyQueryUsing: function (Builder $query, Get $get) {
return $query
->where('client_id', $get('client_id'))
->orderBy('number', 'desc');
})
10 replies
FFilament
Created by w5m on 10/4/2024 in #❓┊help
How to get all options from table filter in table header action?
Unfortunately, the client_id and project_id components are dependent Selects, so the latter is dynamically populated based on the former...
10 replies
FFilament
Created by w5m on 10/4/2024 in #❓┊help
How to get all options from table filter in table header action?
I was trying to avoid executing another database query, as the list of relevant project id's already exists in the Select component's list of options.
10 replies
FFilament
Created by w5m on 10/4/2024 in #❓┊help
How to get all options from table filter in table header action?
I'm trying to get the full list of options from the project_id Select component (not the currently selected option, which ->getState() returns), so that I can decide which id from the list should be used to build a URL to navigate to. I'm guessing I need to use the ->getOptions() method, but I'm not sure how I get access to the Select component.
10 replies
FFilament
Created by w5m on 8/5/2024 in #❓┊help
Pass form data (`$state`) to `ChartWidget` in resource Create page
That's worked nicely - many thanks Leandro 👍
9 replies
FFilament
Created by w5m on 8/5/2024 in #❓┊help
Pass form data (`$state`) to `ChartWidget` in resource Create page
The action is defined in the footerActions of a form Section component.
9 replies
FFilament
Created by w5m on 8/5/2024 in #❓┊help
Pass form data (`$state`) to `ChartWidget` in resource Create page
I get the following error "Using $this when not in object context", so would I need to pass a closure in as the 2nd argument to the dispatch() method?
9 replies
FFilament
Created by w5m on 8/5/2024 in #❓┊help
Pass form data (`$state`) to `ChartWidget` in resource Create page
Thanks for your response @Leandro Ferreira
9 replies
FFilament
Created by w5m on 7/31/2024 in #❓┊help
Custom "Save" button to create or save a form
trait CanCreateOrSave {
/**
* Calls the appropriate method to either create a new record,
* or save changes to an existing record.
* This method name can be passed to an the ->action() method
* of an Action component.
*/
public function createOrSave(): void
{
if (is_subclass_of($this, \Filament\Resources\Pages\CreateRecord::class)) {
$this->create();
} else if (is_subclass_of($this, \Filament\Resources\Pages\EditRecord::class)) {
$this->save();
}
}
}
trait CanCreateOrSave {
/**
* Calls the appropriate method to either create a new record,
* or save changes to an existing record.
* This method name can be passed to an the ->action() method
* of an Action component.
*/
public function createOrSave(): void
{
if (is_subclass_of($this, \Filament\Resources\Pages\CreateRecord::class)) {
$this->create();
} else if (is_subclass_of($this, \Filament\Resources\Pages\EditRecord::class)) {
$this->save();
}
}
}
6 replies
FFilament
Created by w5m on 7/31/2024 in #❓┊help
Custom "Save" button to create or save a form
A big thank you for your suggestion @Leandro Ferreira - that's a nice way of doing it and I now have a better understanding of which methods the 'save' and 'create' strings were referring to. I slightly adapted the custom method you suggested to fit with my implementation (as I have an additional class named BaseCreateRecord which descends from CreateRecord and introduces some common functionality to child classes)...
6 replies
FFilament
Created by Luiz on 5/14/2024 in #❓┊help
How to show brand logo when sidebar is collapsed on desktop?
16 replies
FFilament
Created by Luiz on 5/14/2024 in #❓┊help
How to show brand logo when sidebar is collapsed on desktop?
Would an alternative solution be to move the brand logo out of the sidebar (the aside element) and into the topbar div element (after the expand & collapse sidebar buttons in the nav sub-element)?
16 replies