ChesterS
ChesterS
FFilament
Created by frame on 4/16/2025 in #❓┊help
Prevent form from closing and show error on action form submit
Hmm I've been trying things out (throwing 💩 in the wall pretty much haha). Not sure if this is better or worse?
->action(function (Form $form, Action $action, $livewire) {
throw ValidationException::withMessages([
$form->getFlatFields()['foo']->getStatePath() => 'Something went wrong',
]);
->action(function (Form $form, Action $action, $livewire) {
throw ValidationException::withMessages([
$form->getFlatFields()['foo']->getStatePath() => 'Something went wrong',
]);
It feels like there should be a better way of doing this 🤔 Anyway, if it works...¯\_(ツ)_/¯
14 replies
FFilament
Created by frame on 4/16/2025 in #❓┊help
Prevent form from closing and show error on action form submit
You can do the same thing in the ->action() part AFAIK
14 replies
FFilament
Created by frame on 4/16/2025 in #❓┊help
Prevent form from closing and show error on action form submit
Not sure if that's what you want, but you can do something like
->after(function ($data, Action $action) {
try {
...
} catch(Throwable ) {
Notification::make()->body('Something went wrong...')->send();
$action->halt();
}
});
->after(function ($data, Action $action) {
try {
...
} catch(Throwable ) {
Notification::make()->body('Something went wrong...')->send();
$action->halt();
}
});
This will prevent the modal from closing. The notification part is optional
14 replies
FFilament
Created by Chinese on 4/3/2025 in #❓┊help
problem with user_id
Wow this thread is wild. ChatGPT + Limewire ?! What a combination of old and new!
27 replies
FFilament
Created by Will 🇬🇹 on 3/28/2025 in #❓┊help
Prevent multiple calls to the same model
I guess that's up to you to decide. I just said that because sometimes an extra find query is no big deal. In any case, if you're in laravel 11+, have a look at this too https://flanger.dev/blog/post/avoid-duplicate-queries-in-filament-closures-for-eloquent-records
8 replies
FFilament
Created by Crispy on 3/20/2025 in #❓┊help
Way to only allow numeric in search dropdown for filament select element?
Sorry I've never had to deal with VoiceOver Screen so I don't know 😦 (I don't even know how to test this). Maybe a different event (other than keydown ?) BTW there's a bug in the above suggestion - it also ignores the backspace so you can't delete anything 😅
11 replies
FFilament
Created by Crispy on 3/20/2025 in #❓┊help
Way to only allow numeric in search dropdown for filament select element?
This is obviously not 'secure' - just a UX improvement
11 replies
FFilament
Created by Crispy on 3/20/2025 in #❓┊help
Way to only allow numeric in search dropdown for filament select element?
You can add this to your select
->extraAttributes([
'x-on:keydown' => 'if($event.which < 48 || $event.which > 57) $event.preventDefault()'
])
->extraAttributes([
'x-on:keydown' => 'if($event.which < 48 || $event.which > 57) $event.preventDefault()'
])
this is just some JS to prevent non-numbers from working. Not sure if the code itself can be improved (i'm not great at JS)
11 replies
FFilament
Created by sparmin on 3/28/2025 in #❓┊help
How to hide filter options and use only the search?
The only way I've found that can avoid this is to either use a ->relationship() on the select (which is not alway possible) or run a custom results with ->getSearchResultsUsing()
9 replies
FFilament
Created by sparmin on 3/28/2025 in #❓┊help
How to hide filter options and use only the search?
This won't work. '->pluck('name', 'number')` will still run the query AFAIK. For example this
Select::make('contacts')
->options(fn() => Contact::query()
->limit(12345)
->pluck('name', 'id')
)
->preload(false)
->searchable(),
Select::make('contacts')
->options(fn() => Contact::query()
->limit(12345)
->pluck('name', 'id')
)
->preload(false)
->searchable(),
ends up in this query being executed on page load
select name, id from contacts where contacts.deleted_at is null limit 12345
select name, id from contacts where contacts.deleted_at is null limit 12345
9 replies
FFilament
Created by Will 🇬🇹 on 3/28/2025 in #❓┊help
Prevent multiple calls to the same model
Sooomething like that
8 replies
FFilament
Created by Will 🇬🇹 on 3/28/2025 in #❓┊help
Prevent multiple calls to the same model
Not with built-in stuff AFAIK. You can set use a computed property but I'm not sure if it's worth the hassle. Something like
public int $selected_inventory_id = null;

#[Computed]
public function inventoryCount(): ?int {
return $this->selected_inventory_id
? Inventory::find($this->selected_inventory_id)->quantity
: null;
}
public int $selected_inventory_id = null;

#[Computed]
public function inventoryCount(): ?int {
return $this->selected_inventory_id
? Inventory::find($this->selected_inventory_id)->quantity
: null;
}
and
TextInput::make('quantity')
->required()
->numeric()
->maxValue(fn(Get $get) => $this->inventoryCount ?? null)
->helperText(fn (Get $get) => $this->inventoryCount ? ['quantity' => $this->inventoryCount] : null),
TextInput::make('quantity')
->required()
->numeric()
->maxValue(fn(Get $get) => $this->inventoryCount ?? null)
->helperText(fn (Get $get) => $this->inventoryCount ? ['quantity' => $this->inventoryCount] : null),
8 replies
FFilament
Created by sparmin on 3/28/2025 in #❓┊help
How to hide filter options and use only the search?
Add a limit to your query?
Warranty::query()
->distinct('number')
->limit(25)
->pluck('number', 'number'),
Warranty::query()
->distinct('number')
->limit(25)
->pluck('number', 'number'),
9 replies
FFilament
Created by shabxs on 3/21/2025 in #❓┊help
Filament\Forms\Components\Select::isOptionDisabled(): Argument #2 ($label) must be of type string,
I could be wrong though
17 replies
FFilament
Created by shabxs on 3/21/2025 in #❓┊help
Filament\Forms\Components\Select::isOptionDisabled(): Argument #2 ($label) must be of type string,
That might be the problem. AFAIK you can't have both. It's either an enum or a relationship. So keep one or the other.
17 replies
FFilament
Created by chrispage1 on 3/25/2025 in #❓┊help
Additional actions in wizard step
I don't think you will find anything. From what I can see in the template, there's nothing that can be used to add extra buttons vendor/filament/forms/resources/views/components/wizard.blade.php Could be wrong though ¯\_(ツ)_/¯
8 replies
FFilament
Created by shabxs on 3/21/2025 in #❓┊help
Filament\Forms\Components\Select::isOptionDisabled(): Argument #2 ($label) must be of type string,
How does that work?
17 replies
FFilament
Created by shabxs on 3/21/2025 in #❓┊help
Filament\Forms\Components\Select::isOptionDisabled(): Argument #2 ($label) must be of type string,
Wait, this is both a relationship and an enum?
17 replies
FFilament
Created by flex on 3/13/2025 in #❓┊help
Get the block's key when using ->extraItemActions()
I guess you can try using $component->getChildComponents() ?
Builder::make('stuff')
->extraItemActions([
\Filament\Forms\Components\Actions\Action::make('testAction')
->icon('heroicon-m-user')
->action(function ($state, array $arguments, $component): void {
dd($component->getChildComponents()[0]->getName());
})
])
->blocks([
Block::make('test')
->schema([
TextInput::make('content'),
])
])
Builder::make('stuff')
->extraItemActions([
\Filament\Forms\Components\Actions\Action::make('testAction')
->icon('heroicon-m-user')
->action(function ($state, array $arguments, $component): void {
dd($component->getChildComponents()[0]->getName());
})
])
->blocks([
Block::make('test')
->schema([
TextInput::make('content'),
])
])
5 replies
FFilament
Created by flex on 3/13/2025 in #❓┊help
Get the block's key when using ->extraItemActions()
What do you mean 'what type of block it is?' You can get the uuid in the $arguments parameter An example can be found here https://filamentphp.com/docs/3.x/forms/fields/repeater#adding-extra-item-actions-to-a-repeater
5 replies