F
Filament11mo ago
xfly

Old value in relationship manager

hi, how can i get the old value of a TextInput in a Rule? Forms\Components\TextInput::make('portion') ->rule('lte:' . 100 - $this->getOwnerRecord()->process_shareholders_portion - OLDVALUE) ->numeric() ->live() ->required(), i tried many ways but i can't get it work. the sum of the portions always needs to be max 100 but needs to check the portions of other shareholders. i get the process_shareholders_portion from the process model casted. thank you in advance.
2 Replies
Dennis Koch
Dennis Koch11mo ago
Since the record wasn't updated yet the old value should still be in $record? Try
->rule(fn ($record) => 'lte' - $record->portion)
->rule(fn ($record) => 'lte' - $record->portion)
xfly
xflyOP11mo ago
Thank you!
Want results from more Discord servers?
Add your server