F
Filament4mo ago
Abi

RelationManger `save` isn't working

Got an issue with one of the RelationManagers. The EditAction doesn't seem to save the data. I do get the notification for successfully saved, but don't see an UPDATE query in the logs. I am logging all the queries during save, but i only see SELECT queries being executed when clicking on the save button of the EditAction. Not sure why this is happening. Doesn't seem to happen on other RelationManagers
8 Replies
toeknee
toeknee4mo ago
Was there any changs actually made? no update query will be run if no change was acutally made
Abi
AbiOP4mo ago
Yes a change was made to the form.
Abi
AbiOP4mo ago
@toeknee here is a screencast https://share.cleanshot.com/ktsvNVyX
CleanShot Cloud
CleanShot 2025-06-11 at 21.02.26
Video uploaded to CleanShot Cloud
toeknee
toeknee4mo ago
If you refresh the table? Is that field also fillable on the model?
Abi
AbiOP4mo ago
yes when I refresh the page, it still shows the same data before the update
toeknee
toeknee4mo ago
Can you provide your edit action code?
Abi
AbiOP4mo ago
Its the RelationManager and so have the form() method. And I added the following to the EditAction
->after(function (Tables\Actions\EditAction $action) {
ray($action->getFormData());
}),
->after(function (Tables\Actions\EditAction $action) {
ray($action->getFormData());
}),
and it always returns [] here is what the form() method looks like
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Section::make('Content')
->statePath('section_content')
->visible(fn(Forms\Get $get) => $get('content_type') === 'link')
->schema([
Forms\Components\TextInput::make('data')
->label('Link Text')
->required()
->maxLength(255),
Forms\Components\TextInput::make('link')
->label('Link')
->required()
->maxLength(255),
]),

Forms\Components\Section::make('Content')
->statePath('section_content')
->visible(fn(Forms\Get $get) => $get('content_type') === 'remote_video')
->schema([
Forms\Components\TextInput::make('data')
->label('Video URL')
->required()
->maxLength(255),
]),

Forms\Components\Section::make('Content')
->statePath('section_content')
->visible(fn(Forms\Get $get) => $get('content_type') === 'remote_image')
->schema([
Forms\Components\TextInput::make('data')
->label('Image URL')
->required()
->maxLength(255),
Forms\Components\Textarea::make('alt')
->label('Image Alt Text')
->maxLength(1000),
]),
]);
}
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Section::make('Content')
->statePath('section_content')
->visible(fn(Forms\Get $get) => $get('content_type') === 'link')
->schema([
Forms\Components\TextInput::make('data')
->label('Link Text')
->required()
->maxLength(255),
Forms\Components\TextInput::make('link')
->label('Link')
->required()
->maxLength(255),
]),

Forms\Components\Section::make('Content')
->statePath('section_content')
->visible(fn(Forms\Get $get) => $get('content_type') === 'remote_video')
->schema([
Forms\Components\TextInput::make('data')
->label('Video URL')
->required()
->maxLength(255),
]),

Forms\Components\Section::make('Content')
->statePath('section_content')
->visible(fn(Forms\Get $get) => $get('content_type') === 'remote_image')
->schema([
Forms\Components\TextInput::make('data')
->label('Image URL')
->required()
->maxLength(255),
Forms\Components\Textarea::make('alt')
->label('Image Alt Text')
->maxLength(1000),
]),
]);
}
I am showing the field based on the content_type column based on the row I am trying to edit Pretty straight forward code, just not sure why the update isn't working, and still getting the notification. But no errors Have the debug bar and when I look at the queries executed for each livewire request, don't see any update queries but just selects it feels like a SELECT is being called before the update causing the data to reset it doesn't cause the page to reload @toeknee any other advice that I can do to debug and see what is the issue?
toeknee
toeknee4mo ago
So the edit icon, do you have that action code? You are also setting the section_content as the state path though which seems wrong, when you set them all, so the last one will replace all the others?

Did you find this page helpful?