This post https://octobercms.com/forum/post/dropdown-shows-its-value-than-key-name-in-list-controller there is a solution for list controller to display values instead of keys from dropdown in forms.
Although this works fine, it generates another problem. When editing a record, dropdown in the form does not display selected value. Instead it shows an empty dropdown (default value) to select the options, while the filed in the database has a proper key value. When I remove aforementioned code from my model, and get back to having keys in my list controller, the dropdown is correctly populated when editing.
Any help would be appreciated.
Ok I managed this thanks to this
Simply, not use any method in your model, instead in in your columns.yaml use select with a custom SQL query:
homecol: label: 'Colonna Home' type: text searchable: true sortable: true select: CASE WHEN (homecol = '0' ) THEN 'Nessuna' WHEN (homecol = '1') THEN 'Sinistra' ELSE 'Destra' END
1-2 of 2