Skip to Content Skip to Menu

Radio button - disable an option

  • AchLive
  • AchLive
  • OFFLINE
  • Posts: 253
  • Thanks: 14
  • Karma: 3
2 years 1 week ago - 2 years 6 days ago #331566 by AchLive
Hi everyone, I have created a radio button field with three options. Is there any way to disable one of the options if the value of another field is true?
Thanks for the support
Last edit: 2 years 6 days ago by AchLive. Reason: Solved status

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
2 years 1 week ago #331588 by krileon
Replied by krileon on topic Radio button - disable an option
Only way to do that is to use CB Code Field then use its Code Radio Buttons fieldtype. Now you can specify using PHP what the radio options are. This allows you to use PHP to conditionally output what buttons are available. If this depends on another field you can have your code radio buttons field update itself when that other field changes using CB Core Fields Ajax and its Update On behavior. Below is a simple example.

Text Field
Name: cb_mytext

Code Radio Buttons
Name: cb_mybuttons
Parameters > Code > Code (PHP):
Code:
if ( '[cb_mytext]' === 'Test' ) { return [ 'opt1' => 'Option 1', 'opt2' => 'Option 2' ]; } return [ 'opt1' => 'Option 1', 'opt2' => 'Option 2', 'opt3' => 'Option 3' ];
Integrations > CB Core Fields Ajax
Update On: cb_mytext

In this example if cb_mytext has the value of Test then options 1 and 2 will display otherwise options 1, 2, and 3 will display. It should dynamically update during profile edit and registration as cb_mytext is edited.


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.

Please Log in or Create an account to join the conversation.

  • AchLive
  • AchLive
  • OFFLINE
  • Posts: 253
  • Thanks: 14
  • Karma: 3
2 years 6 days ago #331673 by AchLive
Replied by AchLive on topic [SOLVED] Radio button - disable an option
Thanks so much for the support, it was what I was looking for.
The following user(s) said Thank You: krileon

Please Log in or Create an account to join the conversation.

  • AchLive
  • AchLive
  • OFFLINE
  • Posts: 253
  • Thanks: 14
  • Karma: 3
2 years 5 days ago #331678 by AchLive
Replied by AchLive on topic Radio button - disable an option
I need to know one more thing.
For having already selected one of the options what should I add to the code?
Thank you

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
2 years 5 days ago #331682 by krileon
Replied by krileon on topic Radio button - disable an option
Depends on what you want to do. You could have it add the option back in if it's not in the available options or just leave it so it doesn't display.


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.

Please Log in or Create an account to join the conversation.

  • AchLive
  • AchLive
  • OFFLINE
  • Posts: 253
  • Thanks: 14
  • Karma: 3
2 years 5 days ago #331683 by AchLive
Replied by AchLive on topic Radio button - disable an option
Okay thanks

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum