Ric Le Poidevin
Ric Le Poidevin
FFilament
Created by NolanN on 2/12/2024 in #❓┊help
Redirect to a url after action
@NolanN Did you mange to get this to work? I have a similar issue, needing to redirect after an action
8 replies
FFilament
Created by OrdinaryDev on 10/6/2023 in #❓┊help
How to trigger a form save from another action?
@OrdinaryDev Did you find a solution to saving from the action? I have the same issue. Seems like it should be simple as I think a lot of people will want to save their data before running an action.
5 replies
FFilament
Created by Ric Le Poidevin on 3/5/2024 in #❓┊help
Prohibits on Checkbox not working
I can use a custom rule like so which fixes this. I think it’s the only way to make it work as the built-in rules don’t always play well with checkboxes
Forms\Components\Checkbox::make('start_immediately')
->rules([
function(Get $get) {
return function (string $attribute, $value, Closure $fail) use ($get) {
if ($value && $get('start_date')) {
$fail('Please select either start immediately, a start date or leave both blank.');
}
};
}
]),
Forms\Components\DatePicker::make('start_date')
->prefixIcon('heroicon-o-calendar')
->minDate(now())
->native(false),
Forms\Components\Checkbox::make('start_immediately')
->rules([
function(Get $get) {
return function (string $attribute, $value, Closure $fail) use ($get) {
if ($value && $get('start_date')) {
$fail('Please select either start immediately, a start date or leave both blank.');
}
};
}
]),
Forms\Components\DatePicker::make('start_date')
->prefixIcon('heroicon-o-calendar')
->minDate(now())
->native(false),
4 replies
FFilament
Created by Ric Le Poidevin on 3/1/2024 in #❓┊help
On Selects is it possible to make the createOptionForm button clearer
@awcodes thanks, this worked, anywhere I can make a feature request as I think have some customisability over the display of the select create button would be valuable
11 replies
FFilament
Created by Ric Le Poidevin on 3/1/2024 in #❓┊help
On Selects is it possible to make the createOptionForm button clearer
For anyone looking at how to do this with a hintAction
Forms\Components\Select::make('Contact')
->label('Primary contact')
->relationship('contact', 'name')
->hintAction(
Action::make('Add contact')
->icon('heroicon-m-user-plus')
->form(fn(Form $form) => ContactResource::form($form))
->action(function ($data) {
// do anything you need with your data here
$data['company_id'] = auth()->user()->current_company_id;

$contact = new Contact($data);
$contact->save();
}),
),
Forms\Components\Select::make('Contact')
->label('Primary contact')
->relationship('contact', 'name')
->hintAction(
Action::make('Add contact')
->icon('heroicon-m-user-plus')
->form(fn(Form $form) => ContactResource::form($form))
->action(function ($data) {
// do anything you need with your data here
$data['company_id'] = auth()->user()->current_company_id;

$contact = new Contact($data);
$contact->save();
}),
),
11 replies
FFilament
Created by Ric Le Poidevin on 3/1/2024 in #❓┊help
On Selects is it possible to make the createOptionForm button clearer
Ok, thank you, I will investigate!
11 replies
FFilament
Created by Ric Le Poidevin on 3/1/2024 in #❓┊help
On Selects is it possible to make the createOptionForm button clearer
What do you mean? 🙂
11 replies
FFilament
Created by Ric Le Poidevin on 12/13/2023 in #❓┊help
How to get current record on Table action using a custom form field
Thinking about this a but more, the other option would be to access the record in the Field’s class class BraintreePayment extends Field but calling $this->getRecord() errors: Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization
3 replies
FFilament
Created by Ric Le Poidevin on 11/29/2023 in #❓┊help
Liveware inputs not updating state
Fixed: I need to use x-model="state.user.givenName" not x-bind:value="state.user.givenName" Not sure where I got bind from as wrote it months ago!
4 replies
FFilament
Created by Ric Le Poidevin on 11/29/2023 in #❓┊help
Liveware inputs not updating state
No description
4 replies
FFilament
Created by Ric Le Poidevin on 11/6/2023 in #❓┊help
Multi-tenancy and createOptionForm on Select, Field 'company_id' doesn't have a default value
Here’s now to do it for anyone finding this: createOptionAction() is where you need to pass in your additional data
Forms\Components\Select::make('Contact')
->createOptionForm(fn(Form $form) => ContactResource::form($form))
->createOptionAction(fn ($action) => $action->mutateFormDataUsing(function ($data) {
$data['company_id'] = auth()->user()->current_company_id;

return $data;
})),
Forms\Components\Select::make('Contact')
->createOptionForm(fn(Form $form) => ContactResource::form($form))
->createOptionAction(fn ($action) => $action->mutateFormDataUsing(function ($data) {
$data['company_id'] = auth()->user()->current_company_id;

return $data;
})),
14 replies
FFilament
Created by Ric Le Poidevin on 11/6/2023 in #❓┊help
Multi-tenancy and createOptionForm on Select, Field 'company_id' doesn't have a default value
there’s nowhere that runs on the create option form, it’s only used when creating a standalone form as far as I can see. I shall need to try digging deeper
14 replies
FFilament
Created by Ric Le Poidevin on 11/6/2023 in #❓┊help
Multi-tenancy and createOptionForm on Select, Field 'company_id' doesn't have a default value
No description
14 replies
FFilament
Created by Ric Le Poidevin on 11/6/2023 in #❓┊help
Multi-tenancy and createOptionForm on Select, Field 'company_id' doesn't have a default value
And if I use mutateFormDataBeforeCreate in the CreateContact this fires on the form’s own page, but not when used with createOptionForm.
14 replies
FFilament
Created by Ric Le Poidevin on 11/6/2023 in #❓┊help
Multi-tenancy and createOptionForm on Select, Field 'company_id' doesn't have a default value
I can add that to the Edit page for contacts as in the docs https://filamentphp.com/docs/3.x/panels/resources/editing-records#customizing-data-before-filling-the-form but this isn’t run for the save operation: ->createOptionForm(fn(Form $form) => ContactResource::form($form)), Do I need to put it somewhere else?
14 replies
FFilament
Created by Ric Le Poidevin on 10/6/2023 in #❓┊help
Best way to manage single record resource?
Thank you!
4 replies
FFilament
Created by Ric Le Poidevin on 10/5/2023 in #❓┊help
getCurrentPanel returning wrong panel
Fixed it. I was applying my middleware in the Laravel kernel file, not the middleware section of the panel’s config. So it looks like the default panel is loaded by Laravel then replaced later.
return $panel
->id('seeker')
->path('seeker')
...
->middleware([
EncryptCookies::class,
...
ApplyApplicantScopes::class,
])
return $panel
->id('seeker')
->path('seeker')
...
->middleware([
EncryptCookies::class,
...
ApplyApplicantScopes::class,
])
Panel middleware means I don’t even need to do the check in my middleware code, that’s already done!
4 replies
FFilament
Created by jop00 on 9/6/2023 in #❓┊help
Hide relationship manager table from Edit view
For anyone landing here, this is what I needed to do as the route could be null:
public static function getRelations(): array
{
if (request()->route()?->getName() === 'filament.admin.resources.vacancies.view') {
return [
RelationManagers\ApplicationsRelationManager::class,
];
} else {
return [];
}
}
public static function getRelations(): array
{
if (request()->route()?->getName() === 'filament.admin.resources.vacancies.view') {
return [
RelationManagers\ApplicationsRelationManager::class,
];
} else {
return [];
}
}
8 replies
FFilament
Created by Ric Le Poidevin on 9/27/2023 in #❓┊help
SaveFormAction works in footer but not header
Amazing, thank you! I think I had something like that. Still getting my head around how it all works, but that fixed my problem. Thanks!
5 replies
FFilament
Created by Ric Le Poidevin on 9/26/2023 in #❓┊help
Save form before running action
For anyone finding this here is the solution that worked for me I removed the save buttons from the Create and Edit pages and added a submitAction to my wizard to handle saving the form.
Forms\Components\Wizard::make([...])
->submitAction(\Filament\Actions\Action::make('create')
->label('Save')
->submit('create'))->columnSpanFull(),
Forms\Components\Wizard::make([...])
->submitAction(\Filament\Actions\Action::make('create')
->label('Save')
->submit('create'))->columnSpanFull(),
When saved the user is redirected to the Edit page for the resource. I then added a header action as below.
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
$this->getSaveFormAction()
->submit(null)
->action('save'),
\Filament\Actions\Action::make('Publish')
->closeModalByClickingAway(false)
->slideOver()
->icon('heroicon-o-check-badge')
->form([
BraintreePayment::make('payment')
->viewData([
...
])
])
->disabled(function (Vacancy|null $record) {
return $record?->is_published;
})
->modalSubmitAction(false)
->modalCancelActionLabel('Close'),
];
}
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
$this->getSaveFormAction()
->submit(null)
->action('save'),
\Filament\Actions\Action::make('Publish')
->closeModalByClickingAway(false)
->slideOver()
->icon('heroicon-o-check-badge')
->form([
BraintreePayment::make('payment')
->viewData([
...
])
])
->disabled(function (Vacancy|null $record) {
return $record?->is_published;
})
->modalSubmitAction(false)
->modalCancelActionLabel('Close'),
];
}
18 replies