© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
5 replies
inluxc

Rules in TextInput breaks server.

When i add the following rule to an TextInput and i try to save the form is breaks the server and i need to restart it.

  Forms\Components\TextInput::make('slug')
      ->hint('Translatable')
      ->hintColor('primary')
      ->hintIcon('heroicon-m-language')
      ->disabled()
      ->rules([
          function () {
              return function ($value, Closure $fail, $livewire) {
                  // Check if slug belongs to currrent page
                  $count = Sitemap::all()
                      ->where('slug', '=', $value)
                      ->where('resource_id', $livewire->record->getAttribute('id'))
                      ->where('resource_type', 'page')
                      ->count();
                  if ($count > 0) {
                      return;
                  }

                  // Check if slug already exists in another resource
                  $countExists = Sitemap::all()
                      ->where('slug', '=', $value)
                      ->count();
                  if ($countExists > 0) {
                      $fail("The slug already exists in another resource");
                  }
              };
          },
      ])
      ->maxLength(255),
  Forms\Components\TextInput::make('slug')
      ->hint('Translatable')
      ->hintColor('primary')
      ->hintIcon('heroicon-m-language')
      ->disabled()
      ->rules([
          function () {
              return function ($value, Closure $fail, $livewire) {
                  // Check if slug belongs to currrent page
                  $count = Sitemap::all()
                      ->where('slug', '=', $value)
                      ->where('resource_id', $livewire->record->getAttribute('id'))
                      ->where('resource_type', 'page')
                      ->count();
                  if ($count > 0) {
                      return;
                  }

                  // Check if slug already exists in another resource
                  $countExists = Sitemap::all()
                      ->where('slug', '=', $value)
                      ->count();
                  if ($countExists > 0) {
                      $fail("The slug already exists in another resource");
                  }
              };
          },
      ])
      ->maxLength(255),


Can someone point me out what I am doing wrong?
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

`->hidden()` method on TextInput field breaks app
FilamentFFilament / ❓┊help
3y ago
Having TextInput in CreateAction breaks closing modals by clicking outside
FilamentFFilament / ❓┊help
2y ago
Chevron arrow in textInput
FilamentFFilament / ❓┊help
11mo ago