App Connect Data Formatter Support Product Page

Answered

Create a reusable value that contains a stack of ORs and ANDs?

Asked 21 Sep 2023 16:30:16
1
has this question
21 Sep 2023 16:30:16 Bobby Edgar posted:
When it comes to hiding the submit button or other information until a form is completed and valid, creating the stack of conditions takes a long time and really clutters up the code.

is it possible to create a value of "something" that is "true" if "x =y" AND "g!=h" OR ...etc

and then be able to reuse that value to show a div or whatever if "something" is true?

instead of copying and pasting the really long stack of conditions each time?


Replies

Replied 21 Sep 2023 16:47:32
21 Sep 2023 16:47:32 Bobby Edgar replied:
AND why do we have to physically remove the brackets from each value as we stack conditions using the formatter?
Replied 25 Sep 2023 13:42:32
25 Sep 2023 13:42:32 Teodor Kuduschiev replied:

Quoteis it possible to create a value of "something" that is "true" if "x =y" AND "g!=h" OR ...etc

Well, this depends on what exactly would you like to check.
Replied 25 Sep 2023 14:09:59
25 Sep 2023 14:09:59 Bobby Edgar replied:
A form with several inputs. Only want to show the submit button when all of the inputs aren't empty (== '') and are valid. Then also use that logic to show or hide divs or spans.

Instead of copying and pasting ALL of this logic...

 dmx-hide="((((((((inp_GALOM_client_zipcode.value == '' || inp_GALOM_client_email_address.value == '') || inp_GALOM_client_email_address_ver.value == '') || inp_GALOM_client_phone_number.value == '') || inp_GALOM_client_password.value == '') || inp_GALOM_client_password_ver.value == '') || inp_GALOM_client_first_name.value == '') || inp_GALOM_client_last_name.value == '') || inp_GALOM_client_page_name.value == '')">
                    <div id="personal_page_selection" dmx-hide="(((((((inp_GALOM_client_zipcode.invalid || inp_GALOM_client_email_address.invalid) || inp_GALOM_client_email_address_ver.invalid) || inp_GALOM_client_phone_number.invalid) || inp_GALOM_client_password.invalid) || inp_GALOM_client_password_ver.invalid) || inp_GALOM_client_last_name.invalid) || inp_GALOM_client_last_name.invalid)"


Can I setup a value once like "Form_Valid is True" if all of that logic is true.

Then use and reuse "show if Form_Valid == True" etc...
Replied 25 Sep 2023 14:25:22
25 Sep 2023 14:25:22 Teodor Kuduschiev replied:
You can add a variable in the app structure and use similar expressions, but make sure to properly enter them as the expressions depend on how nested the strucure is.
Example - your variable is in the root of the app structure, then your expressions won't just be inp_GALOM_client_email_address.value but depending on the nested level they can be something likeform1.inp_GALOM_client_email_address.value or similar.
Also, to check if an input has a value it's enough to do:

!inp_GALOM_client_email_address.value


This will return true when the input value is empty. Also i see you are using || (logical or) and not && (logical and) but your explanation says:
Quotewhen all of the inputs aren't empty

so you should check what you want to do exactly.

So when you build your expression in a variable, for example called var1, when you use var1.value it will return true or false.

Not to mention all of this is much easier to build and really advanced in Wappler, than what you have here in DW.
Replied 25 Sep 2023 21:39:50
25 Sep 2023 21:39:50 Bobby Edgar replied:
Thanks.

Wappler is WAY too expensive to justify, so I'll stick with Dreamweaver.

Reply to this topic