form validation over multiple fields

4 years 4 months ago #315709 by Allwinds007
Replied by Allwinds007 on topic form validation over multiple fields
getting closer ;-)

with [value] I get better, but not yet perfect solutions.

This code
return ( ( (int) '[value]' > 0 ) || ( (int) '[cb_haus2]' > 0 ) );
gives me only results, that are evaluated with "true" (even when the fields sum up to 0).

that's why I'm not sure whether the fields are evaluated against each other as they should.

I also tried to return the result as false and as true (with an if - else -statement). But it did't work as supposed.

I really need your help for this tricky question - thank's a lot in advanced

Please Log in to join the conversation.

4 years 4 months ago #315716 by krileon
Replied by krileon on topic form validation over multiple fields
The code provided will evaluate to true or false as is intended. Validation code must return true for valid and false for invalid. It currently will evaluate to true as long as 1 of the 2 fields is greater than 0. If that's not what you were wanting then I don't understand what you're wanting it to validate against. If you want to validate against the sum of the 2 fields you'd need to use the below code with [value] replacing [cb_field1] or [cb_field2] where needed.

return ( ( (int) '[cb_field1]' + (int) '[cb_field2]' ) > 0 );


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 to join the conversation.

4 years 4 months ago #315720 by Allwinds007
Replied by Allwinds007 on topic form validation over multiple fields
Sorry, me again.
Everything you say is logical and as a php programmer I understand the code quiet well.
What I don't understand is the behaving of my form on the frontend.
As you can get a better insight in my problem I made a short screen-movie.
Please have a look at it under this www.dropbox.com/s/wu7lobewybj19mn/Code%20validation.mp4?dl=0URL .

You'r my last hope - if you can't give me an indication what could be wrong - I will try to reach my goal with a work-around.

Sorry, but CB behaves really a little bit strange at this point - as far as I see.

thanks for your help

Please Log in to join the conversation.

4 years 4 months ago #315723 by krileon
Replied by krileon on topic form validation over multiple fields
The validation on cb_garten2 is incorrect. In its validation you need to replace [cb_garten2] with [value]. Anytime you're trying to use the fields own value in the validation you need to use [value]. Its validation should be as follows.

return ( ( (int) '[value]' + (int) '[cb_haus2]' ) > 0 );

The validation on cb_haus2 should be as follows.

return ( ( (int) '[value]' + (int) '[cb_garten2]' ) > 0 );

That should work and does in my tests, but there's a caching bug that's causing existing values to validate a little oddly. Have added a bug ticket to fix the caching issue.

forge.joomlapolis.com/issues/7795


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 to join the conversation.

4 years 4 months ago #315725 by krileon
Replied by krileon on topic form validation over multiple fields
Ok, the caching issue has now been fixed in latest CB Code Field and CB Query Field validation integrations. The above exact usecase appears fully functional in my tests. Please update to latest builds releases as of now using the above usecase code.


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: Allwinds007

Please Log in to join the conversation.

4 years 4 months ago #315730 by Allwinds007
Replied by Allwinds007 on topic form validation over multiple fields
perfect - now it works fine

sometimes it takes two times to save new values, but it works ;-)

It is not possible to change directly
from field1 = 1 and field2 = 0
to field 1 = 0 and field2 = 1

But I think we and our members will come clear with this.

Thank you for you help and your endurance ;-)

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.188 seconds

Facebook Twitter LinkedIn