© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3mo ago•
19 replies
BigBlueMonkey

ViewField -> ViewData variable not available

✅ Solved4️⃣v4
Rather simple:
ViewField::make('pdf_viewer_in_modal')
  ->label('')
  ->view('filament.resources.test.components.pdf-viewer')
  ->viewData([
      'classes' => 'h-[80vh]',
  ])
ViewField::make('pdf_viewer_in_modal')
  ->label('')
  ->view('filament.resources.test.components.pdf-viewer')
  ->viewData([
      'classes' => 'h-[80vh]',
  ])


<div class="w-full bg-gray-100 dark:bg-gray-800 rounded-lg flex flex-col {{ $classes }}">
    @if ($this->selectedFile)
        <div class="flex-grow h-full">
            <iframe src="{{ $this->selectedFile->getTmpUrlAttribute() }}" class="w-full h-full border-0"></iframe>
        </div>
    @else
        <div class="w-full h-full flex items-center justify-center">
            <p class="text-gray-500">No file selected or available.</p>
        </div>
    @endif
</div>
<div class="w-full bg-gray-100 dark:bg-gray-800 rounded-lg flex flex-col {{ $classes }}">
    @if ($this->selectedFile)
        <div class="flex-grow h-full">
            <iframe src="{{ $this->selectedFile->getTmpUrlAttribute() }}" class="w-full h-full border-0"></iframe>
        </div>
    @else
        <div class="w-full h-full flex items-center justify-center">
            <p class="text-gray-500">No file selected or available.</p>
        </div>
    @endif
</div>


Results in Undefined variable $classes ?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Inject other field state into viewData on ViewField
FilamentFFilament / ❓┊help
17mo ago
how use viewData value at ViewField in the blade view
FilamentFFilament / ❓┊help
3y ago
viewfield
FilamentFFilament / ❓┊help
3y ago
Having viewData with value of another field available
FilamentFFilament / ❓┊help
2y ago