Forums

Need help pulling info into the database....

arrick 23 Mar, 2015
Hello All,

I have a couple questions.

Item #1
Currently I have s custom code that is below that is in my "On submit" section of the form located at http://mwforms.miworksmo.org/dvop-app:

<?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['eligibility'] = $qualified;
?>


What I would like to do is have a column in my table that is labeled "Eligibility" that takes the "$qualified" variable and puts it into the code. I am unsure how to tackle this.

Item #2:

Currently there is a text box labeled "ApplicantOSMISID" and I would like to auto populate that based on the following information: take the first 3 letters of {ApplicantLastName}, the first 2 letters of {ApplicantFirstName} and the MMDD of {ApplicantDateOfBirth} and combine them... so if name and birthdate were as follows: John Thomas 12/13/1974 then it would calculate {OSMISID} with JohTh1213

Item #3
I have successfully connected chronoconnectivity to that form, and am able to open and edit all fields that are in the form... How do I open the form so that ALL Data is available, but only certain fields are editable?

Thanks in advance,
Arrick.
GreyHead 24 Mar, 2015
1 Likes
Hi Arrick.,

1. If the column is called Eligibility then use that in the $form->data array e.g. $form->data['Eligibility'] = $qualified;

2. Use a Custom Code action and create the string you need:
<?php
$form->data['OSMISID'] = substr($form->data['ApplicantLastName'], 0, 3).substr($form->data['ApplicantFirstName'], 0, 2).substr($form->data['ApplicantDateOfBirth'], 0, 2).substr($form->data['ApplicantDateOfBirth'], 3, 2);
?>
!! May need debugging !!

3. In the Extra Options add readonly=readonly for the elements that you want to be read only - or only display them as text.

Bob
arrick 24 Mar, 2015
Thanks for the response Bob... I already have the $form->data['eligibility'] = $qualified; in the last line before ?> in the custom php.... it doesnt save to the database at this time, even though the column name is eligibility ... any ideas on that?
GreyHead 25 Mar, 2015
1 Likes
Hi Arrick,

The Debugger should show you the MySQL query that is being created (I'm not sure if that displayed when linked to CC but should be OK if you test the form in stand-alone mode from the Test Form icon).

Bob
arrick 25 Mar, 2015
Where would I put the debugger and pull the results from it? I have it set right before the DB Save action and dont know?
arrick 25 Mar, 2015
Ok, I got the debugger working.... And eligibility now works.

Now I have a new issue...I have added a hidden field that is called submittedOn and in the php code I have added


I have tried both creating the field in the table, and dropping/adding a new table to autopopulate the fields....
$form->data['submittedOn'] = date("m/d/Y");

right before the ?> tag.

If you go to http://mwforms.miworksmo.org/dvop-app and fill the form out, submit it, you can see in the debugger that there are no errors, and that [submittedOn] => mm/dd/yyyy for the date called in the date("m/d/Y").

Now that is not saving into the database... I have linked to a screenshot of the database table in phpmyadmin so you can see that the table is exact, not sure why it isn't inserting....

http://mwforms.miworksmo.org/images/formimgs/dvop-table.png

Thanks for all the help so far.
GreyHead 25 Mar, 2015
Answer
1 Likes
Hi Arrick,

ChronoForms caches the table info - if you change or add columns please click the Clear Cache icon in the Forms Manager toolbar to allow the records to be updated.

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