Form inside Livewire Component:
In a livewire component I want to put a form, in this a select that must take the data from the Bank model.
How do I enable new records to be created in the Bank model?
public function form(Form $form): Form
{
return $form
->schema([
Select::make('bank_id')
->searchable()
->inlineLabel()
->translateLabel()
->preload()
->searchDebounce(500)
->loadingMessage('Loading banks...')
->getSearchResultsUsing(fn (string $search): array => Bank::where('bank', 'like', "%{$search}%")->limit(50)->pluck('bank', 'id')->toArray())
->getOptionLabelUsing(fn ($value): ?string => Bank::find($value)?->name),
])->columns(2)
->statePath('data');
}
1 Reply
if you can use it with a relation, you can do this:
https://filamentphp.com/docs/3.x/forms/fields/select#creating-a-new-option-in-a-modal