© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•6mo ago•
1 reply
Mouse0270

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.
image.png
image.png
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Using formatStateUsing on Select relationship
FilamentFFilament / ❓┊help
2y ago
Render markdown using InfoLists TextEntry
FilamentFFilament / ❓┊help
3y ago
Repeater - formatStateUsing
FilamentFFilament / ❓┊help
3y ago
TextEntry bulleted()
FilamentFFilament / ❓┊help
2y ago