docusign / code-examples-php

Docusign PHP code examples and launcher
https://developers.docusign.com/
MIT License
47 stars 42 forks source link

adding some logics in checkboxes in Example 32 with Embedded sign #29

Closed iyyappanpwilco closed 3 years ago

iyyappanpwilco commented 3 years ago

Hi ,

I have added 3 checkboxes in the page $check1 = new Checkbox(['document_id' => '1', 'page_number' => '7', 'x_position' => '150', 'y_position' => '420', 'tab_label' => 'ckAuthorization']); $check2 = new Checkbox(['document_id' => '1', 'page_number' => '7', 'x_position' => '150', 'y_position' => '460', 'tab_label' => 'ckAuthentication']); $check3 = new Checkbox(['document_id' => '1', 'page_number' => '7', 'x_position' => '150', 'y_position' => '500', 'tab_label' => 'ckAgreement']); I need logic that if one and two selected then the 3rd check box must be hidden and if the 3rd checkbox is checked then the 1 and 2 must be hidden

Kindly help me how to add it

AaronWDS commented 3 years ago

I myself haven't done this before but looking around, I do see a fellow named David on our old support forums provided a solution for conditional checkboxes a couple years ago:

... it would be complicated. So you start with your Checkboxes with the "validation" set as "Select at least '0'", we will call this Checkbox Group A. This makes the checkboxes optional (as you may know). Now you add a Text box for each of the checkboxes, setting a value of "1" in each text box setting these Text boxes as "read-only", set the Formatting as white background so these do not appear on the document, and give them a Data Label. Each Text box needs to be conditionally triggered by its corresponding checkbox in Checkbox Group A, so Checkbox A1 if selected should conditionally trigger Textbox1 and so on. Now add a Formula field for each Text field, we will refer to them as Formula 1,2, and 3. Each "Formula" field needs to add up the values of Text box 1 through Text box 3 (also set to white background so they disappear on the document). Now add 3 sets of the additional checkboxes because these will need to be layered on top of each other and each set will be triggered (conditional) on a Formula field, we will call them Checkbox Group B, C, and D. So add conditionality to Formula 1, setting the value as "1.00" and hold shift while selecting each of the checkboxes in Group B. Then add conditionality to Formula 2 setting the value as "2.00" and hold shift while selecting each of the checkboxes in Group C. Then add conditionality to Formula 3 setting the value as "3.00" and hold shift while selecting each of the checkboxes in Group D. Basically you now have conditions that will open up checkbox group B, C, or D if any of the checkboxes are selected on checkbox group A. Now you layer Checkbox Group B, C, and D on top of each other.

Alright that would or should do what you are looking for and I added an image to try to show the field structure, but basically if any number of checkboxes in Checkbox Group A are selected, whether that is 1 or 2 or 3 it will trigger the Text box values which then get added in the Formulas which then 1 out of the 3 formulas will trigger 1 of 3 layered sets of checkboxes but only "1" set. Hence satisfying what I perceive as your Use Case.

checkboxes