how can I insert the placeholder value into database?
I'm using filament-v2, in my create form I have a few calculative fields for which I'm using placeholders and I want these calculative values to get inserted into the database along with other field values of the form. What's wrong with my code, any help would be appreciated.
TextInput::make('premium')->label('Premium Amount'),
TextInput::make('no_passengers')->numeric()->label('Number of Passengers')
->reactive(),
Placeholder::make('prsnl_acdnt_prm')->label('Personal Acc. Premium')
->reactive() ->content(
function ($get) {
$pap = $get('no_passengers') * 200;
return $pap;
}),
Placeholder::make('total_premium')->label('Total Premium Amount')->reactive()
->content(
function ($get) {
$pap = $get('no_passengers') * 200;
$sum = $get('premium') + $get('prsnl_acdnt_prm') + $pap;
return $sum;
})
Solution:Jump to solution
I would suggest to use
TextInput
with ->disabled()
and ->dehydrated()
then no need to do extra when saving.. or If you want placeholder, then (maybe) you can get the value and make use of mutateFormDataBeforeCreate
3 Replies
Solution
I would suggest to use
TextInput
with ->disabled()
and ->dehydrated()
then no need to do extra when saving.. or If you want placeholder, then (maybe) you can get the value and make use of mutateFormDataBeforeCreate
thank you for your reply @Vp . yeah TextInput works fine.
Please, could you post a code fragment where you solve your problem.
I have a similar problem and I can't find a way to do it with a TextInput
could you post a code fragment, please