© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•16mo ago
deadbeef

Repeater - Safe Approach to Prepend Data

I can't seem to find a path with the Repeater component to safely add a new item to the start of the list.

I have the two following approaches:
// Use internal Filament events to add the new item and move it to the start of the list
public function addFormItem() {
      $this->mountFormComponentAction('data.criteria', 'add');
      $ids = array_keys($this->data['criteria']);
      $newItemId = array_pop($ids);
      $ids = [$newItemId, ...$ids];
      $this->mountFormComponentAction('data.criteria', 'reorder', [
          'items' => $ids
      ]);
}
// Use internal Filament events to add the new item and move it to the start of the list
public function addFormItem() {
      $this->mountFormComponentAction('data.criteria', 'add');
      $ids = array_keys($this->data['criteria']);
      $newItemId = array_pop($ids);
      $ids = [$newItemId, ...$ids];
      $this->mountFormComponentAction('data.criteria', 'reorder', [
          'items' => $ids
      ]);
}


// Manually add to the state
public function addFormItem()
{
      $newItem = [str()->ulid()->toRfc4122() => ['new-repeater' => 'contents-here']];

      $this->data['criteria'] = $newItem + $this->data['criteria'];
}
// Manually add to the state
public function addFormItem()
{
      $newItem = [str()->ulid()->toRfc4122() => ['new-repeater' => 'contents-here']];

      $this->data['criteria'] = $newItem + $this->data['criteria'];
}


The new item shows up, but they seem to break repeater collapsing functionality. Is there a better way to handle this?
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

How to mutate repeater data?
FilamentFFilament / ❓┊help
3y ago
Refreshing repeater data
FilamentFFilament / ❓┊help
6mo ago
Accessing repeater data
FilamentFFilament / ❓┊help
3y ago
How to prepend next item instead of appending it in a Filament Repeater
FilamentFFilament / ❓┊help
2y ago