Select default is acting up
I'm trying to select a default value based on which field is filled:
but it always selects the same field, how can i fix this?
Select::make('pricing_type')
->label(__('labels.price_is'))
->options([
'per_person' => __('labels.per_person'),
'total' => __('labels.total'),
])
->default(function (?Model $model) {
if ($model) {
return $model->per_person_price !== null ? 'per_person' : 'total';
}
})
->disablePlaceholderSelection(), Select::make('pricing_type')
->label(__('labels.price_is'))
->options([
'per_person' => __('labels.per_person'),
'total' => __('labels.total'),
])
->default(function (?Model $model) {
if ($model) {
return $model->per_person_price !== null ? 'per_person' : 'total';
}
})
->disablePlaceholderSelection(),but it always selects the same field, how can i fix this?