Update TextInput based on Select value
I have two fields:
I would expect that the field would hide if I select option 0 in my Select component. This is not happening. Any ideas what I'm missing here?
Select::make('job_salary_type')
->columnSpanFull()
->label(__('strings.fields.job_salary_type'))
->live()
->default(0)
->options([
0 => __('strings.strings.unknown'),
1 => __('strings.strings.monthly'),
2 => __('strings.strings.yearly'),
]),
TextInput::make('job_salary_avg')
->hidden(function ($get) {
return $get('job_salary_type') === 0;
})
->numeric()
->prefix('€')
->label(__('strings.fields.job_salary_avg'))
->helperText(function ($get) {
$helperText = __(
'strings.strings.average_salary',
['type' => __('strings.strings.per_month')]
);
if ($get('job_salary_type') === 2) {
$helperText = __(
'strings.strings.average_salary',
['type' => __('strings.strings.per_year')]
);
}
return $helperText;
}),Select::make('job_salary_type')
->columnSpanFull()
->label(__('strings.fields.job_salary_type'))
->live()
->default(0)
->options([
0 => __('strings.strings.unknown'),
1 => __('strings.strings.monthly'),
2 => __('strings.strings.yearly'),
]),
TextInput::make('job_salary_avg')
->hidden(function ($get) {
return $get('job_salary_type') === 0;
})
->numeric()
->prefix('€')
->label(__('strings.fields.job_salary_avg'))
->helperText(function ($get) {
$helperText = __(
'strings.strings.average_salary',
['type' => __('strings.strings.per_month')]
);
if ($get('job_salary_type') === 2) {
$helperText = __(
'strings.strings.average_salary',
['type' => __('strings.strings.per_year')]
);
}
return $helperText;
}),I would expect that the field would hide if I select option 0 in my Select component. This is not happening. Any ideas what I'm missing here?