Saving relationships on livewire Action
Hey guys,
I have a strange situation. I created a livewire component with Filament-Actions.
My action looks like this:
blade file:
Problem is, that the "teams" relationship will not be saved and is even not available at $form->getState()
What am I missing?
I have a strange situation. I created a livewire component with Filament-Actions.
My action looks like this:
public function createAction(): Action
{
return CreateAction::make('create')
->label(__('Add page'))
->modalHeading(__('Add a new page'))
->modalDescription(__('bla'))
->modalSubmitActionLabel(__('Create'))
->form([
TextInput::make('name')
->label(__('Name'))
->required(),
Grid::make()
->schema([
Select::make('status')
->label(__('Status'))
->required()
->options([
0 => 'Hidden',
1 => 'Visible',
]),
Select::make('teams')
->label(__('Teams'))
->required()
->preload()
->multiple()
->searchable()
->relationship('teams', 'name'),
]),
RichEditor::make('content')
->label(__('Content'))
->required(),
Hidden::make('sort')
->default(fn () => Page::count() + 1),
])
->model(Page::class)
->action(
fn (Form $form) => dd($form->getState()) // Getting state - there is no teams relation
);
}public function createAction(): Action
{
return CreateAction::make('create')
->label(__('Add page'))
->modalHeading(__('Add a new page'))
->modalDescription(__('bla'))
->modalSubmitActionLabel(__('Create'))
->form([
TextInput::make('name')
->label(__('Name'))
->required(),
Grid::make()
->schema([
Select::make('status')
->label(__('Status'))
->required()
->options([
0 => 'Hidden',
1 => 'Visible',
]),
Select::make('teams')
->label(__('Teams'))
->required()
->preload()
->multiple()
->searchable()
->relationship('teams', 'name'),
]),
RichEditor::make('content')
->label(__('Content'))
->required(),
Hidden::make('sort')
->default(fn () => Page::count() + 1),
])
->model(Page::class)
->action(
fn (Form $form) => dd($form->getState()) // Getting state - there is no teams relation
);
}blade file:
<div>
{{ $this->createAction }}
<x-filament-actions::modals />
</div><div>
{{ $this->createAction }}
<x-filament-actions::modals />
</div>Problem is, that the "teams" relationship will not be saved and is even not available at $form->getState()
What am I missing?
Solution
->dehydrated()->dehydrated() in the select will show it in the $data$data array