How to format dependable, readonly(calculated) fields?

I have a form with 3 TextInput fields:
  • amount (user enters value here)
  • price (comes from db)
  • sum (calculated field/value)
    Forms\Components\TextInput::make('amount')
      ->numeric()
      ->reactive()
      ->afterStateUpdated(function (callable $set, callable $get, $state) {
          $this->calculate($set, $get);
      })
      ->required(),
    Forms\Components\TextInput::make('price')
      ->extraInputAttributes(['readonly' => true]),
    Forms\Components\TextInput::make('sum')
      ->extraInputAttributes(['readonly' => true]),

    I can use Mask for amount field but how can i format read-only fields price and sum?
Was this page helpful?