Trying to open createOptionAction

I'm trying to open a createOptionAction from a livewire component that's in a modal called from a viewField, I already tried to use {{ $this->modal }} inside the livewire component's blade but it only added a 1 the the modal. Not sure how to proceed since {{ $this->modal }} worked on diferent ocassions but not on this one. Calling of the livewire component in modal
<x-filament::modal id="edit_employee_contract" width="5xl">
@livewire('edit-contract-employee', ['employee_id' => $getRecord()->id, 'modal' => '1', 'modal_id' => 'edit_employee_contract'])
</x-filament::modal>
<x-filament::modal id="edit_employee_contract" width="5xl">
@livewire('edit-contract-employee', ['employee_id' => $getRecord()->id, 'modal' => '1', 'modal_id' => 'edit_employee_contract'])
</x-filament::modal>
The component where I'm trying to open the createOptionAction
php
Select::make('department_id')
->label(__('employees.contracts_tab.department'))
->options(Department::all()->pluck('name', 'id'))
->searchable()
->required()
->createOptionForm([
TextInput::make('name')
->required(),
])
->createOptionAction(function (Forms\Components\Actions\Action $action) {
return $action
->modalButton(__('employees.create_department_button'))
->modalHeading(__('employees.create_department'))
->modalWidth('xl');
})
->createOptionUsing(function ($data) {
return Department::create($data)->getKey();
}),
php
Select::make('department_id')
->label(__('employees.contracts_tab.department'))
->options(Department::all()->pluck('name', 'id'))
->searchable()
->required()
->createOptionForm([
TextInput::make('name')
->required(),
])
->createOptionAction(function (Forms\Components\Actions\Action $action) {
return $action
->modalButton(__('employees.create_department_button'))
->modalHeading(__('employees.create_department'))
->modalWidth('xl');
})
->createOptionUsing(function ($data) {
return Department::create($data)->getKey();
}),
1 Reply
Veur
Veur13mo ago
You need to define a relationship on the Select: https://filamentphp.com/docs/3.x/forms/fields/select#creating-a-new-option-in-a-modal Also make sure you have set up the form's model. Otherwise, Filament doesn't know which model to use to retrieve the relationship from.
Want results from more Discord servers?
Add your server