[SOLVED] Conditional field label in dropdown select

7 years 11 months ago - 7 years 11 months ago #282642 by svictor
Hi and thanks for CB!

I need to change labels in a dropdown list according to the member’s gender.

I have created a field for member’s gender. I understood how i can use it conditionnaly on the parameters tab of my target field. This tutorial made it very clear. I also read this .

However I don’t understand how to use the "if" test to substitute specifically some labels of my dropdown list.

I’m sure my use case is quite common for languages like French. My dropdown is for the member’s occupation. I simply need the occupation to show in its masculine/feminine form according to the person’s gender. What’s the best way to achieve this ?

Please Log in to join the conversation.

7 years 11 months ago #282657 by krileon
Replied by krileon on topic Conditional field label in dropdown select
Once you've your select field with the values you want you need to add your substitutions to its profile value layout found by editing the field in CB > Field Management then under Parameters > Layouts. Below is an example of a substitution usage to adjust the display based off the fields value. For the purpose of an example i'll use "male" and "female" values and name the field "cb_gender".

[cb:if cb_gender="male"]I am Male[/cb:if]
[cb:if cb_gender="female"]I am Female[/cb:if]

What text you supply is entirely up to you. You can even use HTML if you like. So for example if I wanted an image instead I'd use the below.

[cb:if cb_gender="male"][/cb:if]
[cb:if cb_gender="female"][/cb:if]

Next if you need to alter a select field values based off their gender you can use the below for example.

[cb:if cb_gender="male" and cb_occupation="teacher"]
I am a Male Teacher
[/cb:if]

[cb:if cb_gender="female" and cb_occupation="teacher"]
I am a FemaleTeacher
[/cb:if]

See the bottom of the below substitution tutorial for further IF usage examples.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18353-using-substitutions-throughout-cb


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: svictor

Please Log in to join the conversation.

7 years 11 months ago #282683 by svictor
Replied by svictor on topic Conditional field label in dropdown select
Thanks, that works.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.208 seconds

Facebook Twitter LinkedIn