Support » Plugin: cformsII » How can I migrate from insert_custom_cform to insert_cform

  • Hi,

    so we’re using a really old version of cforms (11.7.3) and now need to upgrade to a newer version since we are upgrading to PHP7.

    I tried at least 10 different versions an I either have the issue that insert_custom_cform is not working or that the version I tested is not fully compatible with PHP 7 (giving errors when submitting a form).

    So the only option I have is rebuild the forms with a new version running on PHP7

    So insert_custom_cform is no longer supported and whenever I use insert_cform I’m getting either a blank form or having issues with the way the form is calling it’s fieldnames (not using the number of form properly in tags ids and classes, therefore messes up other parts of my code).

    Here is my old code:

    <?
    $fields = array();
    
    $formdata = array(
            array('Contact Information','textonly',0,0,0,0,0),
    		array('First Name','textfield',0,1,0,0,0),
    		array('Last Name','textfield',0,1,0,0,0),
    		array('Your Address','textfield',0,1,0,0,0),
    		array('Your City','textfield',0,1,0,0,0),
    		array('Your State#...|...#Alberta|AB#Alaska|AK#Alabama|AL#Arkansas|AR#Arizona|AZ#British Columbia|BC#California|CA#Colorado|CO#Connecticut|CT#District Of Columbia|DC#Delaware|DE#Florida|FL#Georgia|GA#Hawaii|HI#Iowa|IA#Idaho|ID#Illinois|IL#Indiana|IN#Kansas|KS#Kentucky|KY#Louisiana|LA#Massachusetts|MA#Manitoba|MB#Maryland|MD#Maine|ME#Michigan|MI#Minnesota|MN#Missouri|MO#Mississippi|MS#Montana|MT#New Brunswick|NB#North Carolina|NC#North Dakota|ND#Nebraska|NE#New Hampshire|NH#New Jersey|NJ#Newfoundland and Labrador|NL#New Mexico|NM#Nova Scotia|NS#Northwest Territories|NT#Nunavut|NU#Nevada|NV#New York|NY#Ohio|OH#Oklahoma|OK#Ontario|ON#Oregon|OR#Pennsylvania|PA#Prince Edward Island|PE#Puerto Rico|PR#Quebec|QC#Rhode Island|RI#South Carolina|SC#South Dakota|SD#Saskatchewan|SK#Tennessee|TN#Texas|TX#Utah|UT#Virginia|VA#Vermont|VT#Washington|WA#Wisconsin|WI#West Virginia|WV#Wyoming|WY#Yukon Territory|YT','selectbox',0,1,0,0,0),
    		array('Zip Code','textfield',0,1,0,0,0),
    		array('Your Phone','textfield',0,1,0,0,0),
    		array('Your E-Mail','textfield',0,1,1,0,0),
    		array('Vehicle Donation Information','textonly',0,0,0,0,0),
    		array($allkids,'selectbox',0,1,0,0,0),
    		array('Year','textfield',0,1,0,0,0),
    		array('Make','textfield',0,1,0,0,0),
    		array('Model','textfield',0,1,0,0,0),
    		array('Mileage','textfield',0,0,0,0,0),
    		array('Vehicle VIN','textfield',0,0,0,0,0),
    	    array('Vehicle Location','textonly',0,0,0,0,0),
    		array('Same as above','checkbox',0,0,0,0,0),
    		array('Vehicle Location Address','textfield',0,0,0,0,0),
    		array('City','textfield',0,0,0,0,0),
    		array('State#...|...#Alberta|AB#Alaska|AK#Alabama|AL#Arkansas|AR#Arizona|AZ#British Columbia|BC#California|CA#Colorado|CO#Connecticut|CT#District Of Columbia|DC#Delaware|DE#Florida|FL#Georgia|GA#Hawaii|HI#Iowa|IA#Idaho|ID#Illinois|IL#Indiana|IN#Kansas|KS#Kentucky|KY#Louisiana|LA#Massachusetts|MA#Manitoba|MB#Maryland|MD#Maine|ME#Michigan|MI#Minnesota|MN#Missouri|MO#Mississippi|MS#Montana|MT#New Brunswick|NB#North Carolina|NC#North Dakota|ND#Nebraska|NE#New Hampshire|NH#New Jersey|NJ#Newfoundland and Labrador|NL#New Mexico|NM#Nova Scotia|NS#Northwest Territories|NT#Nunavut|NU#Nevada|NV#New York|NY#Ohio|OH#Oklahoma|OK#Ontario|ON#Oregon|OR#Pennsylvania|PA#Prince Edward Island|PE#Puerto Rico|PR#Quebec|QC#Rhode Island|RI#South Carolina|SC#South Dakota|SD#Saskatchewan|SK#Tennessee|TN#Texas|TX#Utah|UT#Virginia|VA#Vermont|VT#Washington|WA#Wisconsin|WI#West Virginia|WV#Wyoming|WY#Yukon Territory|YT','selectbox',0,0,0,0,0),
    		array('Zip','textfield',0,0,0,0,0),
    		array('Does this vehicle run?','checkbox',0,0,0,0,0),
    		array('Additional Information','textonly',0,0,0,0,0),
    		array('How did you hear about us?#Google Search#Yahoo Search#Bing Search#Radio#Newspaper#Post Card#Thrift Store Flyer#Previous Donor#Other','selectbox',0,1,0,0,0),
    		array('Message','textarea',0,0,0,0,0),
    		array('User||^[\s]*$|err:No Spam please','textfield',0,0,0,0,0),
    		array('Have Pics? Attach them here.','upload',0,0,0,0,0),
                    array('<a href="#" id="addScnthome">Add More</a>','textonly',0,0,0,0,0)
    		);
    
    $i=0;
    foreach ( $formdata as $field ) {
    	$fields['label'][$i]        = $field[0];
    	$fields['type'][$i]         = $field[1];
    	$fields['isdisabled'][$i]   = $field[2];
    	$fields['isreq'][$i]        = $field[3];
    	$fields['isemail'][$i]      = $field[4];
    	$fields['isclear'][$i]      = $field[5];
    	$fields['isreadonly'][$i++] = $field[6];
    }
    
     insert_custom_cform($fields,'8');
    
    			?>

    How would I call this form and data properly using the insert_cform function?

    Thanks a lot for the help.

    • This topic was modified 4 months, 1 week ago by  .
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author bgermann

    (@bgermann)

    So first things first: As the readme points out you should upgrade to v14.6.0.5 on PHP5.x first to migrate your settings. I have this as a starting point because I did not test a migration path from v11.

    Can you post the errors that you get with cforms2 v14.14? This is the last version that supports both PHP7 and insert_custom_cform.

    To switch from insert_custom_cform to insert_cform just change argument order to insert_cform('8', $fields);

    tinodesigns

    (@tinodesigns)

    Thank you. I will do the migration and then report back on the results and with error reporting, if any.

    Best,
    Tino

    tinodesigns

    (@tinodesigns)

    Hi,

    so the migration to version 14.6.05 worked fine and after saving all the forms settings again I had no other issues except a few minro styling bugs.

    However when I switch to version 14.14 I can generate a form fine BUT it loads the settings from the form number 1 in the wp-admin area and not the form number 8 like specified in the code (insert_cform(‘8’, $fields); OR insert_custom_cform($fields, ‘8’);) same issue on both functions.

    The fieldset populates fine however. Any idea how I can get the settings from form #8 for my autoform?

    Thanks,
    Tino

    • This reply was modified 4 months ago by  .
    • This reply was modified 4 months ago by  .
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.