Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

maha-pappan's avatar

Passing value of Form Column to a Variable

I am a newbie to Filament Laravel PHP Framework. I have OrdersResource.php with the following columns:

order_date, order_dateline; and days_to_complete

I want the Form to automatically display the date difference in number of day once the user enter order_date and order_dateline. Below is my code:

Forms\Components\DatePicker::make('order_date') ->format('Y-m-d H:i:s') ->timezone('Asia/Singapore') ->displayFormat('d/m/Y') ->native(false) ->label('Order Date') ->closeOnDateSelection(), //------------------

Forms\Components\DatePicker::make('order_dateline') ->format('d/m/Y H:i:s') ->timezone('Asia/Singapore') ->displayFormat('d/m/Y') ->native(false) ->label('Order Dateline') ->closeondateselection() ->reactive() ->live() ->afterStateUpdated(function($state, $set){ $OrderDate = Carbon::parse('order_date'); $OrderDateline = Carbon::parse('order_dateline'); $set('daystocomplete', $OrderDate->diffInDays($OrderDateline));

My attempts for 4 days have been a failure. I need all the help that I can get. Please assist.

Thanks,

0 likes
0 replies

Please or to participate in this conversation.