Vexmachina
Vexmachina
FFilament
Created by Vexmachina on 6/1/2024 in #❓┊help
Not able to select newly created options using CreateOptionsForm until refresh
Hey y'all, I've created some monstrosity. I'm sure there's a better way of doing this, and if you can help point me in the right direction I'd really appreciate it. I added CreateOptionsForms to each of the select fields, and they work, but the issue is that after creation, while I can see the option in the dropdown, if I try to actually select it it will pretend to let me for half a second, but then reset the select field to "Select an option". It's not actually selectable until I refresh the page. A second issue is, after creating the option, i'd like that new option to be automatically selected by the field. I've tried to accomplish this with the Product select but the approach I've taken just isn't doing anything. I'm imagining this is related to the first issue, the option not actually being selectable.
5 replies
FFilament
Created by Vexmachina on 5/29/2024 in #❓┊help
Searchable and reactive select fields not functioning
So essentially what I'm trying to achieve is having a form where everything is disabled except the first field, which after getting selected enables the next field and loads options based on the first selection, which then enables the next. This all works as intended until I make the fields searchable(). Once I do that, after I select the company, the next field goes from dark to light, indicating that it's no longer disabled, but clicking it does nothing. I can't select anything or really interact with it. Again, if I remove the searchable(), then the field gets enabled as intended, showing the relevant options, and it all works. Any help would be much appreciated!
Forms\Components\Select::make('company_id')
->label('Company')
->options(\App\Models\Company::all()->pluck('name', 'id'))
->reactive()
->afterStateUpdated(function (callable $set) {
$set('product_id', null);
$set('tos_id', null);
})
->searchable()
->required(),

Forms\Components\Select::make('product_id')
->label('Product')
->disabled(fn (callable $get) => !$get('company_id'))
->afterStateUpdated(function (callable $set) {
$set('tos_id', null);
})
->searchable()
->getSearchResultsUsing(fn (string $search, callable $get): array =>
\App\Models\Product::where('company_id', $get('company_id'))
->where('name', 'like', "%{$search}%")
->limit(50)
->pluck('name', 'id')
->toArray())
->required(),
Forms\Components\Select::make('company_id')
->label('Company')
->options(\App\Models\Company::all()->pluck('name', 'id'))
->reactive()
->afterStateUpdated(function (callable $set) {
$set('product_id', null);
$set('tos_id', null);
})
->searchable()
->required(),

Forms\Components\Select::make('product_id')
->label('Product')
->disabled(fn (callable $get) => !$get('company_id'))
->afterStateUpdated(function (callable $set) {
$set('tos_id', null);
})
->searchable()
->getSearchResultsUsing(fn (string $search, callable $get): array =>
\App\Models\Product::where('company_id', $get('company_id'))
->where('name', 'like', "%{$search}%")
->limit(50)
->pluck('name', 'id')
->toArray())
->required(),
7 replies
FFilament
Created by Vexmachina on 5/28/2024 in #❓┊help
Is there a way to do a combo box form input for creating/editing?
I'd like to give people the ability to type in a text input field, and have it search for any currently existing records that match the text just like you can do with a searchable select field. At the same time, if there are no matching records, I'd like them to be able to save whatever they've written as if it's a textinput field. Is there any simple in way to achieve this? Thank you!
5 replies
FFilament
Created by Vexmachina on 5/26/2024 in #❓┊help
Styling on filament table in custom blade view works great on local dev, broken on server
No description
2 replies