$set another form field, but the new value of that field is not showing in $data array

On the edit form, there is one reactive field. when this field is changed by user, it will $set other several fields' value. On UI, I do see values of those fields are changed. but when dd($data) in mutateFormDataBeforeSave(array $data) those fields are not presented. Here is the partial form:
Forms\Components\TextInput::make('summary_data.total_remittances')
->label('Minus: remittances')
->numeric()
->live()
->default(0.00)
->afterStateUpdated(function( Forms\Set $set, Forms\Get $get, $state){
$difference = (float)$get('summary_data.total_deductions_reported') - (float)$state;
$set('summary_data.difference', $difference);
})
->prefix('82'),
Forms\Components\TextInput::make('summary_data.difference')
->label('Difference')
->numeric()
->disabled()
->default(0.00),
Forms\Components\TextInput::make('summary_data.total_remittances')
->label('Minus: remittances')
->numeric()
->live()
->default(0.00)
->afterStateUpdated(function( Forms\Set $set, Forms\Get $get, $state){
$difference = (float)$get('summary_data.total_deductions_reported') - (float)$state;
$set('summary_data.difference', $difference);
})
->prefix('82'),
Forms\Components\TextInput::make('summary_data.difference')
->label('Difference')
->numeric()
->disabled()
->default(0.00),
. so in the $data, I can see $data['summary_data']['total_remittances'], but there is no$data['summary_data'] ['difference']. thus it failed to save the new value for ['difference']. Is there anything wrong with the above code? thx!
0 Replies
No replies yetBe the first to reply to this messageJoin