laravel / nova-issues

556 stars 34 forks source link

displayUsingLabels() not working in Detail view #4812

Closed iamoat closed 2 years ago

iamoat commented 2 years ago

Description:

displayUsingLabels() not working in Detail view.

Instead, it displays the actual value in DB. However, Index and Update views are Ok.

Detailed steps to reproduce the issue on a fresh Nova installation:

Define a select field in a Nova resource

return [
 Select::make('Type')->options([
     'individual' => __('Individual'),
     'corporate' => __('Corporate')
 ])
    ->searchable()
    ->displayUsingLabels()
];
image image image
davidhemphill commented 2 years ago

Hi, I wasn't able to replicate the issue on my end. If you could reproduce this issue in a fresh Nova installation and update your issue to include the reproduction repository, that would help us diagnose the issue further. Thanks!

iamoat commented 2 years ago

Tried fresh nova install. The issue doesn't exist. It might caused from other package conflicts.

We can close this case.

scramatte commented 1 year ago

Hi,

I've got exactly same issue here @iamoat, do you use some package for localization such spattie transtable? I've temporarily tweaked the displayUsingLabels method into vendor/laravel/nova/src/Fields/Select.php

On index page it works but on detail page the method is never called.

Regards

datashaman commented 1 year ago

In my case, it's because I define my options in a dependsOn() call. But it seems the dependsOn() callback is not called for Select fields on detail pages. 😢