Display 'select' values in Browse Form

Questions related to using nuBuilder Forte.

Display 'select' values in Browse Form

Unread postby Marvo » Thu Nov 18, 2021 6:45 am

Hi

I have a select field, with the options created in list, e.g. 0|Male|1|Female
This works fine in the Edit form

On the Browse form though, the values are shown as 0 or 1 rather than showing Male or Female

How to display the Male/Female on the browse screen and not the list 'index #'

Thanks
Marvo
 
Posts: 12
Joined: Tue Nov 16, 2021 7:41 am
nuBuilder Version: 4.5

Re: Display 'select' values in Browse Form

Unread postby klasyc » Thu Nov 18, 2021 8:06 am

Hi Marvo,

open the form properties, select the Browse tab and wrap your gender column name by the IF SQL statement (https://www.w3resource.com/mysql/control-flow-functions/if-function.php):

Code: Select all
IF(gender = 0, "Male", "Female")


The next possibility would be probably the custom PHP code in Before Browse action.

Hope this helps :)
klasyc
 
Posts: 5
Joined: Fri Nov 12, 2021 12:55 am
nuBuilder Version: 4.5

Re: Display 'select' values in Browse Form

Unread postby Marvo » Thu Nov 18, 2021 8:24 am

Thank you! That worked! However, I have other select fields that 5 or 6 options in the list. I can't use IF this. .... else this...

Is there a similar SQL statement that checks multiple values
if it's 1 then this, if it's 2 then this, if it's 3 then this, if it's 4 then this .........

Thank you!
Marvo
 
Posts: 12
Joined: Tue Nov 16, 2021 7:41 am
nuBuilder Version: 4.5

Re: Display 'select' values in Browse Form

Unread postby kev1n » Thu Nov 18, 2021 9:38 am

Either replace the list with an SQL that pulls the values from a table and then use a join in the browse to retrieve the description for the values or use multiple replace() like

Code: Select all
REPLACE(REPLACE(REPLACE(your_column, '1', 'One'),'2','Two'),'3','Three')
kev1n
nuBuilder Team
 
Posts: 2135
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: Display 'select' values in Browse Form

Unread postby Marvo » Thu Nov 18, 2021 9:38 pm

Thank you - sorted!
Marvo
 
Posts: 12
Joined: Tue Nov 16, 2021 7:41 am
nuBuilder Version: 4.5


Return to General

Who is online

Users browsing this forum: No registered users and 21 guests