• Resolved fuchsws

    (@fuchsws)


    I’m using Real-time creation of dynamic forms – however since version 14.11 those are not working anymore. Last working version is 14.10.1

    Any later version the form get’s displayed just fine (with all the dynamic fields) but after submitting only the first field of those dynamic fields are submitted and displayed. any idea?

    https://wordpress.org/plugins/cforms2/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author bgermann

    (@bgermann)

    You should post some exampe code and which type of fields you generate.

    17thColossus

    (@17thcolossus)

    I have exactly the same problem and I have been trying debugging it without any success for a couple of days. Basically after the dynamically generated form has been submitted only some of the fields are stored in the database (the first few ones, not always the same number of fields for different forms); also, if validation fails, only the above mentioned fields are shown to the user.
    Checking the tracking table for submitted data shows that email address is not persisted in the db (i.e.: the tracking table shows only the form name, the date and the IP), while it is present in postdata.
    The last form that have been successfully submitted on my website is dated January 30th, so I guess something happened when updating from 14.11.2 to 14.11.3.

    17thColossus

    (@17thcolossus)

    So I just found out what happens: while before there was no correspondence between the number of fields defined in the Form settings page of Cforms administration and the fields defined in the PHP code for dynamic generation of a form, now when the form is submitted the number of fields persisted in the database is the one defined in admin page, regardless if it is smaller (dynamic fields exceeding that number are not saved) or greater (extra fields defined in form settings but not in code are saved, and they are empty) than the one defined in PHP.
    I solved this adding placeholder fields to the form in the Form settings page, but I am quite sure this is a bug that should be solved in the next releases.

    Plugin Author bgermann

    (@bgermann)

    Okay, I will check and fix it.

    Thread Starter fuchsws

    (@fuchsws)

    will this be fixed any time soon? I would like to update the plugin without breaking my dynamic forms … thank you!

    Thread Starter fuchsws

    (@fuchsws)

    This is how I fixed it – implemented my own cforms shortcode (and how to implement a spam honeypot!). Now simply use “{spam_honeypot}” as a field using the cforms gui. Can be expanded with any code you need and as much “replacement tags” you need.

    remove_shortcode('cforms');
    add_shortcode( 'cforms', 'my_own_cforms' );
    
    function my_own_cforms ($atts)
    {
        extract( shortcode_atts( array(
    		'name'  => NULL
    	), $atts ) );
    
        if ( empty($name) )
            return;
    
        $cform = cforms2_check_form_name($name);// get form id by name
        $cformsSettings = get_option('cforms_settings');// load all cforms
        $info['cform'] = $cform;
        $formdata = array();
        $cform_fields = array();
    
    	for($i = 1; $i <= $cformsSettings['form'.$cform]['cforms'.$cform.'_count_fields']; $i++)
    	{
    		$field_stat = explode('$#$', $cformsSettings['form'.$cform]['cforms'.$cform.'_count_field_' . $i]);
    
    		$formdata[$i][0] = $field_stat[0];
    		$formdata[$i][1] = $field_stat[1];
    		$formdata[$i][2] = $field_stat[2];
    		$formdata[$i][3] = $field_stat[3];
    		$formdata[$i][4] = $field_stat[4];
    		$formdata[$i][5] = $field_stat[5];
    		$formdata[$i][6] = $field_stat[6];
    
    		if ($field_stat[0] == '{spam_honeypot}') $info['spam_honeypot'] = $i;
        }
    
        // hide (css) spam honey trap "phone" field
        if (!empty($info['spam_honeypot']))
        {
            add_action('wp_footer', function () use ($info) {
                ?><style>#cforms<?php echo $info['cform']; ?>form #li-<?php echo $info['cform']; ?>-<?php echo $info['spam_honeypot']; ?> {display: none}</style><?php
            });
    
            // add dynamic form fields
            $formdata[$info['spam_honeypot']] = array('Telephone number||^$','textfield',0,0,0,0,0);// spam honey trap
        }
    
        $i=0;
        foreach ( $formdata as $field )
        {
        	$cform_fields['label'][$i]        = $field[0];
        	$cform_fields['type'][$i]         = $field[1];
        	$cform_fields['isreq'][$i]        = $field[2];
        	$cform_fields['isemail'][$i]      = $field[3];
        	$cform_fields['isclear'][$i]      = $field[4];
        	$cform_fields['isdisabled'][$i]   = $field[5];
        	$cform_fields['isreadonly'][$i]   = $field[6];
        	$i++;
        }
    
        return cforms2($cform_fields, $cform.'+');
    }
    Plugin Author bgermann

    (@bgermann)

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Dynamic forms’ is closed to new replies.