This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Single checkbox result not exported


  1. villah
    Member

    I am using the checkbox option to create a 'Subscribe me to your newsletter' option at the end of the form. This shows up fine in the backend, but when you export it to XLS/CSV it doesn't show..

    Hans

    Posted 16 years ago #
  2. yuniar

    Oh, I think you just found a small bug for that one.

    Here is how to fix it, edit your export_entries.php file, look around line 193 - 227.
    You will find this block of code:

    //first, reorder columns into the correct position
        $query = "select
        				element_id,
        				element_total_child
        			from
        				ap_form_elements
        		   where
        		   		form_id='$form_id' and element_type != 'section'
        		order by
        				element_position asc";
        $result = do_query($query);
    
        while($row = do_fetch_result($result)){
    		$element_id  = $row['element_id'];
    		$total_child = $row['element_total_child'];
    
    		if($total_child > 0){
    
    			$max = $total_child + 1;
    			for($i=0;$i<=$max;$i++){
    				if($i == 0){
    					if(in_array('element_'.$element_id,$columns)){
    						$temp_columns[] = 'element_'.$element_id;
    					}
    				}else{
    
    					if(in_array('element_'.$element_id.'_'.$i,$columns)){
    						$temp_columns[] = 'element_'.$element_id.'_'.$i;
    					}
    				}
    			}
    		}else{
    			$temp_columns[] = 'element_'.$element_id;
    		}
    	}


    Replace that block with this one:

    //first, reorder columns into the correct position
        $query = "select
        				element_id,
        				element_total_child,
        				element_type
        			from
        				ap_form_elements
        		   where
        		   		form_id='$form_id' and element_type != 'section'
        		order by
        				element_position asc";
        $result = do_query($query);
    
        while($row = do_fetch_result($result)){
    		$element_id   = $row['element_id'];
    		$total_child  = $row['element_total_child'];
    		$element_type = $row['element_type'];
    
    		if($total_child > 0){
    
    			$max = $total_child + 1;
    			for($i=0;$i<=$max;$i++){
    				if($i == 0){
    					if(in_array('element_'.$element_id,$columns)){
    						$temp_columns[] = 'element_'.$element_id;
    					}
    				}else{
    
    					if(in_array('element_'.$element_id.'_'.$i,$columns)){
    						$temp_columns[] = 'element_'.$element_id.'_'.$i;
    					}
    				}
    			}
    		}else{
    
    			if($element_type != 'checkbox'){
    				$temp_columns[] = 'element_'.$element_id;
    			}else{
    				$temp_columns[] = 'element_'.$element_id.'_1';
    			}
    		}
    	}


    If you have any difficulty with the code, let me know. I'll send you the file directly.
    Thanks for reporting this, I'll update the package with the bugfix.


    MachForm Founder

    Posted 16 years ago #
  3. villah
    Member

    Like a charm! Thanks!

    Hans

    Posted 16 years ago #
  4. yuniar

    No problem! :-)


    MachForm Founder

    Posted 16 years ago #

RSS feed for this topic

Reply