Updating TextEntry using formatStateUsing

I have a custom infolist block that renders previews of html blocks inside filament for my app. It looks like this
PreviewBlockEntry::make('selectedVersionContent')
->label(function ($record, $livewire) {
$version = method_exists($livewire, 'getSelectedVersion')
? $livewire->getSelectedVersion()
: $record->latestVersion();
return $version
? "Content Blocks (Version {$version->version_number})"
: "Content Blocks";
})
->contentField(function ($record, $livewire) {
$version = method_exists($livewire, 'getSelectedVersion')
? $livewire->getSelectedVersion()
: $record->latestVersion();
return $version->content ?? [];
})
PreviewBlockEntry::make('selectedVersionContent')
->label(function ($record, $livewire) {
$version = method_exists($livewire, 'getSelectedVersion')
? $livewire->getSelectedVersion()
: $record->latestVersion();
return $version
? "Content Blocks (Version {$version->version_number})"
: "Content Blocks";
})
->contentField(function ($record, $livewire) {
$version = method_exists($livewire, 'getSelectedVersion')
? $livewire->getSelectedVersion()
: $record->latestVersion();
return $version->content ?? [];
})
And this works great, when I switch versions the content on the site is updated to display the correct version. So I moved on to display the SEO roperties in a similar way
TextEntry::make('meta_title')
->label('Meta Title')
->placeholder('Not set')
->formatStateUsing(function ($record, $livewire) {
$version = method_exists($livewire, 'getSelectedVersion')
? $livewire->getSelectedVersion()
: $record->latestVersion();
return $version?->meta_title;
}),
TextEntry::make('meta_title')
->label('Meta Title')
->placeholder('Not set')
->formatStateUsing(function ($record, $livewire) {
$version = method_exists($livewire, 'getSelectedVersion')
? $livewire->getSelectedVersion()
: $record->latestVersion();
return $version?->meta_title;
}),
This however does not update. Am I doing something wrong, can I not update TextEntry in a similar way? I;ve attached photos showing that the content and version update fine for the Preview blocks, that that appears to be the only thing updating as expected. All of the tables have data, so it should work fine.
No description
No description
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?