F
Filamentβ€’7mo ago
CyladeJS

Autofill on TextInput

Code
TextInput::make('purchase')
->label('Purchase')
->numeric()
->required()
->columnSpan([
'sm' => 12,
'xl' => 4,
'2xl' => 4,
]),

TextInput::make('selling')
->label('Selling')
->numeric()
->required()
->columnSpan([
'sm' => 12,
'xl' => 4,
'2xl' => 4,
]),

TextInput::make('profit')
->label('Profit')
->disabled()
->columnSpan([
'sm' => 12,
'xl' => 4,
'2xl' => 4,
])
TextInput::make('purchase')
->label('Purchase')
->numeric()
->required()
->columnSpan([
'sm' => 12,
'xl' => 4,
'2xl' => 4,
]),

TextInput::make('selling')
->label('Selling')
->numeric()
->required()
->columnSpan([
'sm' => 12,
'xl' => 4,
'2xl' => 4,
]),

TextInput::make('profit')
->label('Profit')
->disabled()
->columnSpan([
'sm' => 12,
'xl' => 4,
'2xl' => 4,
])
Hello, I'm just learning Filament. I need help regarding TextInput autofilling. From the code above, how do I ensure that when I fill in purchase and selling, profit will be automatically filled in?
4 Replies
Dennis Koch
Dennis Kochβ€’7mo ago
You probably want ->live() and ->afterStateUpdated():
MuhamDaily πŸ…₯
MuhamDaily πŸ…₯β€’7mo ago
Can you help me? I don't really understand about afterStateUpdate, so I need a reference I also experienced the same thing
Dennis Koch
Dennis Kochβ€’7mo ago
In this case you would use $get
Placeholder::make('profit')
->label('Profit')
->content(fn ($get) => $get('selling') - $get('purchase')),
Placeholder::make('profit')
->label('Profit')
->content(fn ($get) => $get('selling') - $get('purchase')),
Want results from more Discord servers?
Add your server