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 query field input substitution not working

  • agmatch
  • agmatch
  • OFFLINE
  • Posts: 2
  • Thanks: 0
  • Karma: 0
8 years 5 months ago #281913 by agmatch
I wish to make a tab appear on a condition
The user has to enter date of birth and if they are less that a certain age then we should ask for additional information


I have a field called cb_crew_dob that is of type Date
I have a field called cb_crew_dob_diff that is of type Query / set to show on

In the settings for cb_crew_dob_diff I have :

Parameters tab / Query sub tab
SELECT datediff( '[cb_crew_dob]', now())

and
Integrations tab / CB Query Field sub tab
Query Validation: enabled
Query : SELECT datediff( '[cb_crew_dob]', now())


if I change the query to hard coded a date, then the value show in the form correctly
eg SELECT datediff( '2006-05-01', now())

but if set to pick up the value from the user registration form it get no value and the feild does not show

I am sure that the answer is something simple but i suspect i have missed one setting
Any suggestions welcome

Thanks
Stuart

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
8 years 5 months ago #281945 by krileon
Replied by krileon on topic CB query field input substitution not working
Queries without a table are often rejected by MYSQL unless MYSQL is specifically configured to allow pseudo tables. Use CB Code Field for your needs as there's no reason for SQL in your usage, but instead you just need PHP support. Also note the validation usages use [value] for the value of the field being validated; you only use [FIELD_NAME] for the "Update On" fields.


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.

  • agmatch
  • agmatch
  • OFFLINE
  • Posts: 2
  • Thanks: 0
  • Karma: 0
8 years 5 months ago #281968 by agmatch
Replied by agmatch on topic CB query field input substitution not working
Hi
Thanks for that tip on using the Code field type, I installed the plugin and used the sample code from the site that calculates Extact age and displays on screen

I am still a little unclear on how that updates as the user enters the date of birth, it seems that the code example checks only the value default ( blank) so shows Exact age is: 0 years, 0 months, 0 days but no matter what date i pick on the form for date of birth, i cant seem to get the value in the exact age code field to update

I tried changing the Code to use field substitution
from
$datetime2 = new DateTime($user->cb_crew_dob);
to
$datetime2 = new DateTime($user->[cb_crew_dob]);
and also tried
$datetime2 = new DateTime($user->'[cb_crew_dob]');

but then just got a major error

Do I need do some code on the cb_crew_dob field instead or have i just misunderstood how the substitution syntax works?

Is it possible to dynamically get that updated from the user screen?


Thanks in advance
Stuart

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
8 years 5 months ago #282027 by krileon
Replied by krileon on topic CB query field input substitution not working
Please read the input tooltips carefully. It directly states how you should output to validate or invalidate and how to access the field value.

"Input substitution supported Code. Supply [value] substitution for user input field value. Your code should return true if valid or false if invalid. Variables $field, $user, $value can be used directly in the code."

[value] or $value are both acceptable. If you use [value] it must be treated as a string so you must encase it in quotes (e.g. '[value]').


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.

Moderators: beatnantkrileon
Powered by Kunena Forum