© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
3 replies
hxn

repeater simple vs schema

Hello,

In my model, I have a field named attachments, which is cast as an array. The field can contain multiple path and looks like this:
attachments: "["ticket-attachments\/1715956812\/3v55MYasX2RhfVRoeoaSzdXtzwn9tNKZeNK5vYQz.png","ticket-attachments\/1715956812\/C5Y4cfy3fyiv8XVt7BfKxAXtuztJeWHSDR1GxtcQ.png","ticket-attachments\/1715956812\/suaEW2fieaxAYwONhDn9Oqeo81IWAU4voxEsFr5i.png"]"
attachments: "["ticket-attachments\/1715956812\/3v55MYasX2RhfVRoeoaSzdXtzwn9tNKZeNK5vYQz.png","ticket-attachments\/1715956812\/C5Y4cfy3fyiv8XVt7BfKxAXtuztJeWHSDR1GxtcQ.png","ticket-attachments\/1715956812\/suaEW2fieaxAYwONhDn9Oqeo81IWAU4voxEsFr5i.png"]"


When I use a simple repeater with a ViewField, the $getState() function returns the string path of my images as expected:
Repeater::make('attachments')
    ->simple(
        ViewField::make('attachments')
            ->view('filament.ticket-attachment'),
    )
Repeater::make('attachments')
    ->simple(
        ViewField::make('attachments')
            ->view('filament.ticket-attachment'),
    )


However, when I switch from simple to schema, the $getState() function always returns null:
Repeater::make('attachments')
    ->schema([
        ViewField::make('attachments')
            ->view('filament.ticket-attachment'),
    ])
Repeater::make('attachments')
    ->schema([
        ViewField::make('attachments')
            ->view('filament.ticket-attachment'),
    ])


Here's the custom view:
<div>
    <img class="w-full p-8 mb-4" src="{{ asset('storage/' . $getState()) }}" alt="Attachment">
</div>
<div>
    <img class="w-full p-8 mb-4" src="{{ asset('storage/' . $getState()) }}" alt="Attachment">
</div>


By switching to schema, I'm encountering an issue where the state is not being retrieved correctly. Any guidance on resolving this would be greatly appreciated.
Solution
Because simple returns a flat array, and non-simple returns an array containing the fields. So for non-simple the structure should be

[
  {'attachments': ...},
]
[
  {'attachments': ...},
]
Jump to solution
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

Simple repeater and $get
FilamentFFilament / ❓┊help
13mo ago
formatStateUsing on simple repeater component
FilamentFFilament / ❓┊help
2y ago
Simple Repeater for Filament v2
FilamentFFilament / ❓┊help
3y ago
Repeater::simple does not exist
FilamentFFilament / ❓┊help
3y ago