Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

CB Conditionals - date field

  • jmaridon
  • jmaridon
  • OFFLINE
  • Posts: 49
  • Thanks: 8
  • Karma: 2
11 years 4 weeks ago #234633 by jmaridon
CB Conditionals - date field was created by jmaridon
I am trying to get a field to display based on a date field. I would like the field to display only if the date has already past.

Please let me know what operator and value I can use.

Also, it would be great is you can direct me to any lists of values for other things like radio buttons or check marks.

Thanks!

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48466
  • Thanks: 8280
  • Karma: 1443
11 years 4 weeks ago #234649 by krileon
Replied by krileon on topic CB Conditionals - date field

I am trying to get a field to display based on a date field. I would like the field to display only if the date has already past.

Please let me know what operator and value I can use.

The below may work.

Display: Field conditional self
Field: Your date field
Operator: Less Than or Equal To
Value: [cb:date format="Y-m-d" /]

Please note I have no idea if the above is going to work. It's going to try and do a string to string comparison, which probably won't work. You may need to use a CB Query Field to do the comparison then condition based off its results, but that won't work for jQuery based conditions.

Also, it would be great is you can direct me to any lists of values for other things like radio buttons or check marks.

Single Checkmark fields always store as 0 = No and 1 = Yes. It's best to use Not Equal To 1 or the Is Empty type operators. For other fields like Radios or Multi-Checkbox it's impossible for us to tell you the values as they're install by install supplied by you; edit your fields and you'll see the values you've added to it at the bottom left.


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.

  • jmaridon
  • jmaridon
  • OFFLINE
  • Posts: 49
  • Thanks: 8
  • Karma: 2
11 years 4 weeks ago #234677 by jmaridon
Replied by jmaridon on topic CB Conditionals - date field
Thank you for the reply. Based on what I have read, I am thinking the comparison should work if the formatting is correct. If it still doesn't work with the correct format, then I can try to figure out the query solution.

If I understand correctly, the format has to match exactly, which I think may be preventing this from working.

As I was testing this I tried to make a new date field with the following substitution filled in at registration:
[cb:date format="Y-m-d" /] (1st attempt)
[cb:date format="MM/DD/YYYY" /] (2nd attempt) - first pic attached
I changed the date value in cb configuration from mm/dd/yyyy to mm-dd-yyyy.
[cb:date format="mm-dd-yyyy" /] (3rd attempt)
[cb:date format="MM-DD-YYYY" /] (4th attempt) - second pic attached

What I got each time was a warning on the registration page: "The supplied date is not in valid format," see attached pics. Except for the warning, the substitution worked perfectly using "the current system date." If the system is not reading any of these as the correct format, I would think it will not work as a conditional value, which it does not.

What do I need to do to get cb to recognize the correct date format?
Attachments:

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48466
  • Thanks: 8280
  • Karma: 1443
11 years 4 weeks ago - 11 years 4 weeks ago #234689 by krileon
Replied by krileon on topic CB Conditionals - date field
mm/dd/yyyy is not a valid PHP date format. You'd use m/d/Y for that format. Please see PHPs date function documentation below for further usage information.

php.net/manual/en/function.date.php


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.
Last edit: 11 years 4 weeks ago by krileon.
The following user(s) said Thank You: nant

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

Moderators: beatnantkrileon
Powered by Kunena Forum