© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
3 replies
Majid Al Zariey

JSON Values and Hidden Fields

I am using the following fields attached (statePath) to a JSON column:

Grid::make(2)->statePath('measure')->schema([
                TextInput::make("min")->numeric()->reactive(),
                TextInput::make("max")->numeric()->reactive(),
                TextInput::make("rec-min")->numeric()->reactive()->visible(fn($get) => $get("min") != $get("max")),
                TextInput::make("rec-max")->numeric()->reactive()->visible(fn($get) => $get("min") != $get("max")),
                TextInput::make("default")->numeric()->visible(fn($get) => $get("rec-min") != $get("rec-max")),
            ])->visible(fn($get) => $get('type') == 1 ||$get('type') == 3 || $get('type') == 5),
Grid::make(2)->statePath('measure')->schema([
                TextInput::make("min")->numeric()->reactive(),
                TextInput::make("max")->numeric()->reactive(),
                TextInput::make("rec-min")->numeric()->reactive()->visible(fn($get) => $get("min") != $get("max")),
                TextInput::make("rec-max")->numeric()->reactive()->visible(fn($get) => $get("min") != $get("max")),
                TextInput::make("default")->numeric()->visible(fn($get) => $get("rec-min") != $get("rec-max")),
            ])->visible(fn($get) => $get('type') == 1 ||$get('type') == 3 || $get('type') == 5),


The output of the repeater is a JSON object with the following keys: min, max, rec-min, rec-max, and default. If the values of the min and max fields are equal, the rec-min and rec-max fields are hidden and their values are null in the JSON object.

I have two questions about this:

1- How do I keep the values of the min, max, rec-min, and rec-max fields as integers?
2- Is there an ability to not dehydrate the fields if they are hidden?

All the fields were hidden:

{"min":null,"max":null,"rec-min":null,"rec-max":null,"default":null}
{"min":null,"max":null,"rec-min":null,"rec-max":null,"default":null}


The fields where partially visible with some values:

"min":"10","max":"30","rec-min":null,"rec-max":null,"default":null}
"min":"10","max":"30","rec-min":null,"rec-max":null,"default":null}


Field cast in Eloquent
protected $casts = [
        'measure' => 'json'
    ];
protected $casts = [
        'measure' => 'json'
    ];
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 fields
FilamentFFilament / ❓┊help
3y ago
Include hidden fields
FilamentFFilament / ❓┊help
12mo ago
Empty hidden fields
FilamentFFilament / ❓┊help
2y ago
hidden fields V3
FilamentFFilament / ❓┊help
3y ago