[SOLVED] Using cb:if to check whether a date type userfield is empty

6 years 7 months ago - 6 years 7 months ago #296484 by wbuk
Wonder if you could tell us what's wrong.

We have a userfield with date type.

We want it to display a message if it's empty, and to display the date if it's not.
[cb:if cb_creationdate=""]Contact us to create a Nutrition Plan.
[cb:else]Nutrition Plan created on [value].[/cb:else]
[/cb:if]

However, it does not seem to work, the first statement (Contact us..) does not display at all while the second statement displays regardless of whether the field has a value or not.

Web Buster UK Ltd

Please Log in to join the conversation.

6 years 7 months ago - 6 years 7 months ago #296485 by wbuk
It's okay, we solved our problem. It seems NULL for date should be 0000-00-00.

We changed it to code below and it worked.
[cb:if cb_creationdate="0000-00-00"]Contact us to create a Nutrition Plan.
[cb:else]Nutrition Plan created on [value].[/cb:else]
[/cb:if]

Web Buster UK Ltd
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.172 seconds

Facebook Twitter LinkedIn