Mounting Create Options Forms on a Select
Surely there's a better way to fill the customer_id on the create form modal - what am I missing?
Any thoughts? π
Forms\Components\Select::make('qualification_id')
->relationship('qualification', 'qualification_number', modifyQueryUsing: fn(Builder $query) => $query->orderBy('created_at', 'desc'))
->searchable(['qualification_number', 'search', 'result.location_id', 'result.location_name'])->preload()->reactive()->required()
->createOptionForm(fn(Form $form, Forms\Get $get) => QualificationResource::form($form->model(Qualification::class)))
->createOptionAction(fn(Forms\Components\Actions\Action $action, Get $get) => $action
->mountUsing(function (Form $form) use ($get) {
$form->fill();
$livewire = $form->getLivewire();
data_set($livewire, $form->getStatePath() . '.customer_id', $get('../../customer_id'));
})
)
->getOptionLabelFromRecordUsing(fn(Qualification $record) => view('components.qualification_info', compact('record'))->render())
->createOptionModalHeading('Service Qualification')
->allowHtml(),
Forms\Components\Select::make('qualification_id')
->relationship('qualification', 'qualification_number', modifyQueryUsing: fn(Builder $query) => $query->orderBy('created_at', 'desc'))
->searchable(['qualification_number', 'search', 'result.location_id', 'result.location_name'])->preload()->reactive()->required()
->createOptionForm(fn(Form $form, Forms\Get $get) => QualificationResource::form($form->model(Qualification::class)))
->createOptionAction(fn(Forms\Components\Actions\Action $action, Get $get) => $action
->mountUsing(function (Form $form) use ($get) {
$form->fill();
$livewire = $form->getLivewire();
data_set($livewire, $form->getStatePath() . '.customer_id', $get('../../customer_id'));
})
)
->getOptionLabelFromRecordUsing(fn(Qualification $record) => view('components.qualification_info', compact('record'))->render())
->createOptionModalHeading('Service Qualification')
->allowHtml(),
0 Replies