Forums

Unsure how to tackle the process map on a form...

arrick 06 Mar, 2015
I have a form located at http://mwforms.miworksmo.org that I am working on backend logic for... I have not done this before, but would like some help accomplishing this task so that I can have an example of what to perform in future forms.

Attached is the logic map for the different answers in the backend...

Any help would be greatly appreciated.
GreyHead 09 Mar, 2015
Hi moorear,

I don't think that there is any alternative but to convert your logic map into PHP. It will be something like this:
<?php
$qualified = false;
if ( $form->data['q2a'] == 'Yes' ) {
  if ( $form->data['q2c'] == 'Yes' ) {
    if ( $form->data['q2d'] == 'Yes' || $form->data['q2e'] == 'Yes' || $form->data['q2f'] == 'Yes' ) {
      if ( $form->data['q4a'] == 'Yes' || $form->data['q4b'] == 'Yes' || $form->data['q4c'] == 'Yes' . . .  ) {
        $qualified = 'veteran';
} elseif ( $form->data['q2b'] == 'Yes' ) {
  if ( . . .
    . . .
      $qualified = 'service member';
}
?>
You could probably simplify the logic a bit with careful choice of question names and values.

Bob

PS Please make sure that you don't start input names with digits, that will cause problems.
arrick 09 Mar, 2015
Thank you GreyHead

Considering that I am VERY new to chronoforms, with very little experience with one other website, can you give a little more detail?

Where would I put the php, would it be in a custom code box, or in the setup, etc?

If I get one form done, I may be able to muddle through the rest of it...

One addition to above would be take this eligibility and put a "stamp" at the bottom of the page that says "Eligible" or "Ineligible"...
arrick 09 Mar, 2015
Ok, I have modified the PHP, and know you can put the custom code into the form... however, I haven't got a clue where to put it.


<?php
 $qualified = 'Ineligible';
/*Question 2a*/
	/*Step 1: 2a must be "Yes". If so, proceed to step 2*/
	if ( $form->data['DVOP2a'] == 'Yes' ) {
		/*Step 2: 2c MUST also be "Yes". If so, proceed to step 3*/
		if ( $form->data['DVOP2c'] == 'Yes' ) {
			/*Step 3: At least one of 2d, 2e, or 2f must also be "Yes". If so, proceed to step 4*/
			if ( $form->data['DVOP2d'] == 'Yes' || $form->data['DVOP2e'] == 'Yes' || $form->data['DVOP2f'] == 'Yes' ) {
				/*Step 4: At least one of 4a, 4b, 4c, 4d, 4e, 4f, 4g or 4h must be "Yes". If so, the applicant is to be referred to a DVOP Specialist*/				
				if ( $form->data['DVOP4a'] == 'Yes' || $form->data['DVOP4b'] == 'Yes' || $form->data['DVOP4c'] == 'Yes' || $form->data['DVOP4d'] == 'Yes' || $form->data['DVOP4e'] == 'Yes' || $form->data['DVOP4f'] == 'Yes' || $form->data['DVOP4g'] == 'Yes' || $form->data['DVOP4h'] == 'Yes' ) {
					/*IF eligibility is MET*/
					$qualified = 'Eligible Veteran';
/*Question 2b*/
	/*Step 1: 2b must be "Yes". If so, proceed to step 2*/
	} elseif ( $form->data['DVOP2b'] == 'Yes' ) {
			/*Step 2: Either 2d or 2e must also be "Yes". If so, proceed to step 3 */
			if ( $form->data['DVOP2d'] == 'Yes' || $form->data['DVOP2e'] == 'Yes' ) {
				/*Step 3: Either 4h, 4i, 4j or 4k must be "Yes". If so, the applicant is to be referred to a DVOP Specialist.*/
				if ( $form->data['DVOP4h'] == 'Yes' || $form->data['DVOP4i'] == 'Yes' || $form->data['DVOP4i'] == 'Yes' || $form->data['DVOP4j'] == 'Yes' || $form->data['DVOP4k'] == 'Yes' ) {
					/*IF eligibility is MET*/
					$qualified = 'Eligible Service Member';
/*Question 3a or 3b*/
	/*If either question 3a or 3b is "Yes", the appicant is to be referred to a DVOP Specialist.*/
	} elseif ( $form->data['DVOP3a'] == 'Yes' || $form->data['DVOP3a'] == 'Yes' ) {
		/*IF eligibility is MET*/
		$qualified = 'Eligible Spouse or Family Member';
	 }
 ?>
GreyHead 10 Mar, 2015
1 Likes
Hi moorear,

It would go in a Custom Code action in the form OnSubmit event after any Captcha checks or validation actions and before the Email or DB Save actions.

Bob
arrick 10 Mar, 2015
Ok, here is my "Setup".

Onload
Load CSS
HTML (Render Form)

[b]On Submit[b]
Custom Code - Action Field=DVOP-Eligibility

<?php
 $qualified = 'Ineligible';
/*Question 2a*/
	/*Step 1: 2a must be "Yes". If so, proceed to step 2*/
	if ( $form->data['DVOP2a'] == 'Yes' ) {
		/*Step 2: 2c MUST also be "Yes". If so, proceed to step 3*/
		if ( $form->data['DVOP2c'] == 'Yes' ) {
			/*Step 3: At least one of 2d, 2e, or 2f must also be "Yes". If so, proceed to step 4*/
			if ( $form->data['DVOP2d'] == 'Yes' || $form->data['DVOP2e'] == 'Yes' || $form->data['DVOP2f'] == 'Yes' ) {
				/*Step 4: At least one of 4a, 4b, 4c, 4d, 4e, 4f, 4g or 4h must be "Yes". If so, the applicant is to be referred to a DVOP Specialist*/				
				if ( $form->data['DVOP4a'] == 'Yes' || $form->data['DVOP4b'] == 'Yes' || $form->data['DVOP4c'] == 'Yes' || $form->data['DVOP4d'] == 'Yes' || $form->data['DVOP4e'] == 'Yes' || $form->data['DVOP4f'] == 'Yes' || $form->data['DVOP4g'] == 'Yes' || $form->data['DVOP4h'] == 'Yes' ) {
					/*IF eligibility is MET*/
					$qualified = 'Eligible;
/*Question 2b*/
	/*Step 1: 2b must be "Yes". If so, proceed to step 2*/
	} elseif ( $form->data['DVOP2b'] == 'Yes' ) {
			/*Step 2: Either 2d or 2e must also be "Yes". If so, proceed to step 3 */
			if ( $form->data['DVOP2d'] == 'Yes' || $form->data['DVOP2e'] == 'Yes' ) {
				/*Step 3: Either 4h, 4i, 4j or 4k must be "Yes". If so, the applicant is to be referred to a DVOP Specialist.*/
				if ( $form->data['DVOP4h'] == 'Yes' || $form->data['DVOP4i'] == 'Yes' || $form->data['DVOP4i'] == 'Yes' || $form->data['DVOP4j'] == 'Yes' || $form->data['DVOP4k'] == 'Yes' ) {
					/*IF eligibility is MET*/
					$qualified = 'Eligible';
/*Question 3a or 3b*/
	/*If either question 3a or 3b is "Yes", the appicant is to be referred to a DVOP Specialist.*/
	} elseif ( $form->data['DVOP3a'] == 'Yes' || $form->data['DVOP3a'] == 'Yes' ) {
		/*IF eligibility is MET*/
		$qualified = 'Eligible';
	 } 
$form->data['qualified'] = $qualified;
 ?>

TCPDF - Works as expected (Does not include {qualified}
Email
It is at this point where I am initially trying to introduce the {qualified} parameter, and it is not included... I am pretty sure there is something wrong where elseif on line 16 comes into play in the php code... Can you check it out and let me know please?

Good Day,
{ApplicantName} has submitted an application for DVOP Services.
{qualified}
Thank You.
GreyHead 12 Mar, 2015
Answer
1 Likes
Hi Moorear,

There's a quote ' missing at the end of this line
$qualified = 'Eligible;

Bob
This topic is locked and no more replies can be posted.