Have you ever needed to show extra dynamic information based on the field value in “live” mode? You can do it using prefix/suffix, let's see how.
You need to:
->live()
Forms\Get $get
$get('FIELD')
functionThis is how it looks:
Forms\Components\TextInput::make('price') ->label('Price (in cents)') ->numeric() ->live() ->suffix(function (Forms\Get $get) { return 'EUR ' . number_format($get('price') / 100, 2); }) ->required(),
And for Prefix, we do this:
Forms\Components\TextInput::make('price') ->label('Price (in cents)') ->numeric() ->live() ->prefix(function (Forms\Get $get) { return 'EUR ' . number_format($get('price') / 100, 2); }) ->required(),
A few of our Premium Examples: