Support

Account

Home Forums General Issues How to create dynamic select in ACF and pass to CF7? Reply To: How to create dynamic select in ACF and pass to CF7?

  • I found a solution! I hope it will be useful for someone else in future:

    function add_date_to_cf7() {
    
    	$output = "<select name='date_corso' id='date_corso' onchange='document.getElementById(\"date_corso\").value=this.value;'><option></option>";
    
    	if( have_rows('gruppo_date') ) {
            while( have_rows('gruppo_date') ) {
                the_row();
               
               $output .= '<option value="'.get_sub_field('intervallo_date_corso').'">' .get_sub_field('intervallo_date_corso'). '</option>';
    
            }
        }
    	$output .= "</select>";
    
    	return $output;
    }
    
    wpcf7_add_shortcode('date_corso', 'add_date_to_cf7', true);