© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
46 replies
Emaz

Fields being cleared out due to $set call on other fields

This is a bit hard to explain. I have a repeater with two fields, height and width. The repeater is live as are the 2 TextInputs. Then I have a placeholder which does a bunch of calculations.

 Placeholder::make('')
            ->content(function ($get, $set) {
                $total = static::newCalcTotal($set, $get);
                return new HtmlString("<p></p><br><h1><b>TOTAL $ $total</b></h1>");
             })
 Placeholder::make('')
            ->content(function ($get, $set) {
                $total = static::newCalcTotal($set, $get);
                return new HtmlString("<p></p><br><h1><b>TOTAL $ $total</b></h1>");
             })


newCalcTotal
newCalcTotal
does a bunch of gets, calculates a total for an estimate and sets a few variables. @Dan Harrin gave me some brilliant guidance on this, doing all the calculations in one place and it's working great. Except for this weird issue.

It does NOT touch the height and width fields. Yet clearly, after the calculation, often times the field that has focus (height or width) gets reset to the previous value after the calculation is complete. I validated this by removing the newCalcTotal method call and the problem goes away. One more debug point, which is weird, if I remove the set calls within newCalcTotal the problem also goes away. The $sets I use are unrelated to height/width:

       $set('calculations', $calcString);
        $set('grandTotal', sprintf("%01.2f", $grand ));
        $set('glass_total', $glassTotal);
        $set('hardware_total', $hwTotal);
        $set('labor_total', $laborTotal);
        $set('energy_total', $energy);
        $set('tax_amount', $tax);
        $set('grand_total', $grand);
       $set('calculations', $calcString);
        $set('grandTotal', sprintf("%01.2f", $grand ));
        $set('glass_total', $glassTotal);
        $set('hardware_total', $hwTotal);
        $set('labor_total', $laborTotal);
        $set('energy_total', $energy);
        $set('tax_amount', $tax);
        $set('grand_total', $grand);


I need these sets as they are the result of all the calculations and are stored as part of the record. But if I comment out these $sets, the problem goes away.

I've NO idea how to debug this. It's clearly related to $set although I am NOT setting height or width.
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

Issue with Filament form fields being cleared during live updates
FilamentFFilament / ❓┊help
3mo ago
Password (and other fields) truncates themselves on screen (possibly due to live())
FilamentFFilament / ❓┊help
2y ago
filling fields based on content of other fields.
FilamentFFilament / ❓┊help
3y ago
How to set values on Fields initially?
FilamentFFilament / ❓┊help
8mo ago