Set the HelperText attribute dynamically
Is it possible to dynamically change the HelperText of another field when changing the selected option of a Radiobutton?
Not sure if I need to do this from the Radiobutton, or fetch the value from the field I want to adjust?
Not sure if I need to do this from the Radiobutton, or fetch the value from the field I want to adjust?
Radio::make('job_salary_type')
->columnSpanFull()
->inline()
->reactive()
->label(__('strings.fields.job_salary_type'))
->options([
'1' => __('strings.strings.monthly'),
'2' => __('strings.strings.yearly'),
])
->required()
->afterStateUpdated(function (Closure $set, $get, $state) {
// If the selected option is 1 then change the helperText to monthly
// If the selected option is 2 then change the helperText to yearly
$helperText = __('strings.strings.average_salary', ['type' => __('strings.strings.yearly')]);
// Set the helperText of the 'job_salary_avg' field
// But how?
$set('job_salary_avg', $helperText);
}),Radio::make('job_salary_type')
->columnSpanFull()
->inline()
->reactive()
->label(__('strings.fields.job_salary_type'))
->options([
'1' => __('strings.strings.monthly'),
'2' => __('strings.strings.yearly'),
])
->required()
->afterStateUpdated(function (Closure $set, $get, $state) {
// If the selected option is 1 then change the helperText to monthly
// If the selected option is 2 then change the helperText to yearly
$helperText = __('strings.strings.average_salary', ['type' => __('strings.strings.yearly')]);
// Set the helperText of the 'job_salary_avg' field
// But how?
$set('job_salary_avg', $helperText);
}),