© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•16mo ago•
6 replies
Dima

How to make filament to trim form input?

Laravel uses TrimStrings middleware to automatically trim all form string inputs. However, I noticed that filament allows data to be saved with trailing spaces. How do I enable filament to trim form inputs?
Solution
// its by design from Livewire to skip TrimStrings
// in the source code here
  vendor/livewire/livewire/src/Mechanisms/HandleRequests/HandleRequests.php
// in the boot method they have
$this->skipRequestPayloadTamperingMiddleware();

// which does exactly this
    function skipRequestPayloadTamperingMiddleware()
    {
        .....        
        // as you can see it skip it
        \Illuminate\Foundation\Http\Middleware\TrimStrings::skipWhen(function () {
            return $this->isLivewireRequest();
        });
    }
// its by design from Livewire to skip TrimStrings
// in the source code here
  vendor/livewire/livewire/src/Mechanisms/HandleRequests/HandleRequests.php
// in the boot method they have
$this->skipRequestPayloadTamperingMiddleware();

// which does exactly this
    function skipRequestPayloadTamperingMiddleware()
    {
        .....        
        // as you can see it skip it
        \Illuminate\Foundation\Http\Middleware\TrimStrings::skipWhen(function () {
            return $this->isLivewireRequest();
        });
    }
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

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Trim each input
FilamentFFilament / ❓┊help
3y ago
Trim Text Inputs
FilamentFFilament / ❓┊help
10mo ago
How to connect input form
FilamentFFilament / ❓┊help
3y ago
Rendering filament form input components manually
FilamentFFilament / ❓┊help
3y ago