I have fixed the issue in admin.chronocontact.php by changing the checkbox handlers in these functions:
function maketableChronoContact( $id, $option ) {
global $database, $mosConfig_dbprefix;
$result = $database->getTableList();
if (in_array($mosConfig_dbprefix."chronoforms_".$id, $result)) {
//echo $mosConfig_dbprefix."_chronoforms_".$id;
//echo "A table has already been created for this form";
HTML_ChronoContact::maketableChronoContact( $row, $option, "exists" );
} else {
$row = new mosChronoContact( $database );
$row->load( $id );
$typelist = ' <option value="VARCHAR(255)">Small number of characters - VARCHAR(255)</option>
<option value="TEXT">Medium number of text - TEXT</option>
<option value="LONGTEXT">Biggest number of text - LONGTEXT</option>
<option value="INT(11)">Medium number of numbers ONLY - INT(11)</option>
<option value="INT(22)">Long number of numbers ONLY - INT(22)</option>
<option value="INT(6)">Short number of numbers ONLY - INT(6)</option>
</select>';
$htmlstring = $row->html;
preg_match_all('/name=("|\').*?("|\')/i', $htmlstring, $matches);
$i = 0;
foreach ($matches[0] as $match)
{
$new_match = preg_replace('/name=("|\')/i', '', $match);
$new_match2 = preg_replace('/("|\')/', '', $new_match);
$name = preg_replace('/name=("|\')/', '', $new_match2);
if ($i == 0) {
$html_message.= "<table><table><tr height='10'><td width='30' nowrap><strong>Create column?</strong></td><td width='30'></td><td width='50' class='tablecell1'><strong>Column name</strong></td><td width='30'></td><td class='tablecell2'><strong>Column type</strong></td></tr>";
}
$html_message.= "<tr height='10'><td width='30'><!--<input type='checkbox' name='cf_".$name."' id='cf_".$name."' value='1'>--><input type='checkbox' name='cf_cb[]' id='cf_cb[]' value='".$name."' checked></td><td width='30'></td><td width='50' class='tablecell1'>";
$html_message.= $name."</td><td width='30'></td><td class='tablecell2'>";
$html_message.= '<select name="fieldtype_'.$name.'">'.$typelist."</td></tr>";
$i++;
}
$html_message.= "</table>";
//echo $html_message ;
HTML_ChronoContact::maketableChronoContact( $row, $option, $html_message );
}
}
function finalizetableChronoContact( $option ) {
global $database;
$id = $_POST['formid'];
$row = new mosChronoContact( $database );
$row->load( $id );
$htmlstring = $row->html;
preg_match_all('/name=("|\').*?("|\')/i', $htmlstring, $matches);
$i = 1;
$chrono_fields = array();
$chrono_posts = "";
$table_sql_body = "`cf_id` INT( 11 ) NOT NULL AUTO_INCREMENT , `recordtime` TEXT NOT NULL ,";
foreach($_POST["cf_cb"] AS $key => $value){
$chrono_fields[] = $value;
if($i > 1) $table_sql_body .= " , ";
$table_sql_body .= "`".$value."` ".$_POST['fieldtype_'.$value]. " NOT NULL";
if($i > 1) $chrono_posts .= " , ";
$chrono_posts .= "'\".$"."_POST['$value'].\"'";
$i++;
}
if ( count($chrono_fields) > 0){
$table_sql = "CREATE TABLE `#__chronoforms_".$id."` (";
$table_sql .= $table_sql_body ." , PRIMARY KEY ( `cf_id` )";
$table_sql .= "«») ENGINE = MYISAM ;";
}
//die($table_sql);
$database->setQuery( $table_sql );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
exit();
}
$chrono_onsubmit = "<?php
global $"."database;
$"."database->setQuery( \"INSERT INTO #__chronoforms_".$id." VALUES (
'' , '\". date('Y-m-d').\" - \".date(\"H:i:«»s\"«»).\"' , ".$chrono_posts."«»);\" );
if (!$"."database->query()) {
echo \"<script> alert('\".$"."database->getErrorMsg().\"'); window.history.go(-1); </script>\n\";
}
?>";
$row = new mosChronoContact( $database );
$row->load( $id );
$row->autogenerated = $chrono_onsubmit;
if (!$row->store()) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
mosRedirect( 'index2.php?option='.$option );
}