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

Order of answers in email


  1. matthewbowdengmailcom
    Member

    I built a form with 10 questions, the resulting email contained 10 answers - all in the correct order.

    However I added in an 11th question in position 2 of the form (not at the end of the form) and tested again. The resulting email added the answer after the other answers, not in position 2.

    I understand why this is happening (because the question was added last it is simply appended to the list of answers) but this will need to be fixed.

    Thanks again for a great app!

    Posted 16 years ago #
  2. yuniar

    Hi Matthew,

    You are right, this is indeed a known bug.
    Other users also reporting this. I'll fix it for the next version.

    Thanks!


    MachForm Founder

    Posted 16 years ago #
  3. yuniar

    To fix this bug, modify includes/helper-functions.php

    Around line 166 you'll find this code:

    function send_notification($form_id,$table_data){

    Now, right under that line, paste the code below:

    $query = "select
    				element_id,
    				element_total_child
    			from
    				ap_form_elements
    		   where
    		   		form_id='$form_id'
    		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(array_key_exists('element_'.$element_id,$table_data)){
    						$temp_table_data['element_'.$element_id] = $table_data['element_'.$element_id];
    					}
    				}else{
    
    					if(array_key_exists('element_'.$element_id.'_'.$i,$table_data)){
    						$temp_table_data['element_'.$element_id.'_'.$i] = $table_data['element_'.$element_id.'_'.$i];
    					}
    				}
    			}
    		}else{
    			$temp_table_data['element_'.$element_id] = $table_data['element_'.$element_id];
    		}
    	}
    
    $table_data = array();
    $table_data = $temp_table_data;


    That should fix the bug.


    MachForm Founder

    Posted 16 years ago #

RSS feed for this topic

Reply