-
latristesse
-
-
OFFLINE
-
Fresh Boarder
-
- Posts: 4
-
-
|
Actually, J 1.5 includes a pop-up calendar for form fields - this one line of code can wipe out all that custom calendar code for calendar fields:
echo JHTML::_('calendar', \"\", $row->name, txt.$row->name);
I just can't figure out how to get it so it positions properly. I've put it into the case statement for calendar but the fields are appearing at the top of the form, not next to their labels.
Here is what I have done with forme.html.php: <?php
/**
* @version 1.0.4
* @package RSform! 1.0.4
* @copyright (C) 2007 www.rsjoomla.com
* @license Commercial License, http://www.rsjoomla.com/license/forme.html
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
class forme_HTML{
function test(){
}
function thankyou($form, $Itemid, $did, $fid){
$return_url = ($form->return_url == '') ? str_replace( '&', '&', sefRelToAbs(\"index.php?option=com_forme&Itemid=$Itemid&fid=$fid\"«»)) : $form->return_url;
echo '<div class=\"thankyou\">'.stripslashes($form->thankyou).'</div>';
echo '<input type=\"button\" name=\"ok\" value=\"'._FORME_FRONTEND_THANKYOU_BUTTON.'\" onclick=\"document.location=\''.$return_url.'\'\"/>';
}
function showForm($option, &$form, &$fields){
global $Itemid, $mainframe, $params, $hide_js, $pop, $formeConfig;
$database =& JFactory::getDBO();
//Page title
$mainframe->setPageTitle( $form->title );
$mainframe->addMetaTag( 'title' , $form->title );
//mosCommonHTML::loadCalendar();
eval($form->script_display);
//if we have upload file fields, add enctype
$enctype='';
foreach($fields as $field){
if($field->inputtype=='file upload') $enctype = ' enctype=\"multipart/form-data\"';
}
//parse field template
$formfields = '';
foreach($fields as $field){
if($form->fieldstyle=='') $form->fieldstyle = _FORME_BACKEND_EDITFORMS_FIELDSTYLE_DEFAULT;
if($field->fieldstyle=='') $field->fieldstyle = $form->fieldstyle;
$formfields .= forme_HTML::«»parseFields($field);
}
$action = str_replace( '&', '&', sefRelToAbs('index.php?option=com_forme&fid='.$form->id.'&Itemid='.$Itemid));
//parse form template
if($form->formstyle == '') $form->formstyle = _FORME_BACKEND_EDITFORMS_STYLE_DEFAULT;
$form->formstyle = str_replace('{formtitle}',$form->title,$form->formstyle);
$form->formstyle = str_replace('{formname}',$form->name,$form->formstyle);
$form->formstyle = str_replace('{enctype}',$enctype,$form->formstyle);
$form->formstyle = str_replace('{action}',$action,$form->formstyle);
$form->formstyle = str_replace('{formfields}',$formfields,$form->formstyle);
echo $form->formstyle;
}
function parseErrorMsg($fieldid){
$error = '';
if(isset($_SESSION['formmsg'][$fieldid])){
if(!empty($_SESSION['formmsg'][$fieldid])){
foreach($_SESSION['formmsg'][$fieldid] as $i=>$errmsg){
$_SESSION['formmsg'][$fieldid][$errmsg] = $errmsg;
unset($_SESSION['formmsg'][$fieldid][$i]);
}
foreach($_SESSION['formmsg'][$fieldid] as $errmsg){
$error .= '<br/><span style=\"color: #CF4D4D;font-weight:bold;font-size:10px;\">'.$errmsg.'</span>';
}
unset($_SESSION['formmsg'][$fieldid]);
}
}
return $error;
}
function parseFields($row){
$html = '';
if(!isset($_SESSION['formdata'])) $_SESSION['formdata'] = array();
switch($row->inputtype){
case 'text':
if(isset($_SESSION['formdata'][$row->name])){
$row->default_value = stripslashes($_SESSION['formdata'][$row->name]);
}
$errmsg = forme_HTML::«»parseErrorMsg($row->name);
$html = str_replace('{fieldtitle}',$row->title,$row->fieldstyle);
$html = str_replace('{validationsign}',($row->validation_rule) ? ' *':'',$html);
$html = str_replace('{field}','<input type=\"text\" name=\"form['.$row->name.']\" value=\"'.$row->default_value.'\" id=\"'.$row->name.'\" '.$row->params.' />'.$errmsg,$html);
$html = str_replace('{fielddesc}',$row->description,$html);
break;
case 'button':
$html = str_replace('{fieldtitle}',$row->title,$row->fieldstyle);
$html = str_replace('{validationsign}',($row->validation_rule) ? ' *':'',$html);
$html = str_replace('{field}','<input type=\"button\" name=\"form['.$row->name.']\" value=\"'.$row->default_value.'\" id=\"'.$row->name.'\" '.$row->params.' />',$html);
$html = str_replace('{fielddesc}',$row->description,$html);
break;
case 'reset button':
$html = str_replace('{fieldtitle}',$row->title,$row->fieldstyle);
$html = str_replace('{validationsign}',($row->validation_rule) ? ' *':'',$html);
$html = str_replace('{field}','<input type=\"reset\" name=\"form['.$row->name.']\" value=\"'.$row->default_value.'\" id=\"'.$row->name.'\" '.$row->params.' />',$html);
$html = str_replace('{fielddesc}',$row->description,$html);
break;
case 'submit button':
$html = str_replace('{fieldtitle}',$row->title,$row->fieldstyle);
$html = str_replace('{validationsign}',($row->validation_rule) ? ' *':'',$html);
$html = str_replace('{field}','<input type=\"submit\" name=\"form['.$row->name.']\" value=\"'.$row->default_value.'\" id=\"'.$row->name.'\" '.$row->params.' />',$html);
$html = str_replace('{fielddesc}',$row->description,$html);
break;
case 'image button':
$html = str_replace('{fieldtitle}',$row->title,$row->fieldstyle);
$html = str_replace('{validationsign}',($row->validation_rule) ? ' *':'',$html);
$html = str_replace('{field}','<input type=\"image\" name=\"form['.$row->name.']\" src=\"'.$row->default_value.'\" id=\"'.$row->name.'\" '.$row->params.' />',$html);
$html = str_replace('{fielddesc}',$row->description,$html);
break;
case 'hidden':
$html = str_replace('{fieldtitle}',$row->title,$row->fieldstyle);
$html = str_replace('{validationsign}',($row->validation_rule) ? ' *':'',$html);
$html = str_replace('{field}','<input type=\"hidden\" name=\"form['.$row->name.']\" value=\"'.$row->default_value.'\" id=\"'.$row->name.'\" '.$row->params.' />',$html);
$html = str_replace('{fielddesc}',$row->description,$html);
break;
case 'file upload':
$errmsg = forme_HTML::«»parseErrorMsg($row->name);
$html = str_replace('{fieldtitle}',$row->title,$row->fieldstyle);
$html = str_replace('{validationsign}',($row->validation_rule) ? ' *':'',$html);
$html = str_replace('{field}','<input type=\"file\" name=\"form['.$row->name.']\" value=\"\" id=\"'.$row->name.'\" '.$row->params.' />'.$errmsg,$html);
$html = str_replace('{fielddesc}',$row->description,$html);
break;
case 'password':
$errmsg = forme_HTML::«»parseErrorMsg($row->name);
$html = str_replace('{fieldtitle}',$row->title,$row->fieldstyle);
$html = str_replace('{validationsign}',($row->validation_rule) ? ' *':'',$html);
$html = str_replace('{field}','<input type=\"password\" name=\"form['.$row->name.']\" value=\"'.$row->default_value.'\" id=\"'.$row->name.'\" '.$row->params.' />'.$errmsg,$html);
$html = str_replace('{fielddesc}',$row->description,$html);
break;
case 'radio':
$errmsg = forme_HTML::«»parseErrorMsg($row->name);
if(isset($_SESSION['formdata'][$row->name])) $row->default_value = str_replace('{checked}','',$row->default_value);
$row->default_value = explode(',',$row->default_value);
$radios = '';
foreach ($row->default_value as $i=>$radioset){
$valTitle = explode('|',$radioset);
if(!isset($valTitle[1])) $valTitle[1] = $valTitle[0];
if(isset($_SESSION['formdata'][$row->name])){
if($_SESSION['formdata'][$row->name]==$valTitle[0]){
$valTitle[0] = $valTitle[0].'\" checked=\"checked';
}
}else{
$valTitle[0] = str_replace('{checked}','\" checked=\"checked',$valTitle[0]);
}
$radios .= '<span class=\"radio'.$row->name.'\" style=\"white-space: nowrap\"><input type=\"radio\" name=\"form['.$row->name.']\" id=\"'. $row->name .$i. '\" value=\"'.$valTitle[0].'\" '.$row->params.' /><label for=\"'. $row->name .$i. '\">'. $valTitle[1].'</label></span>';
}
$html = str_replace('{fieldtitle}', $row->title, $row->fieldstyle);
$html = str_replace('{validationsign}', ($row->validation_rule) ? ' *':'', $html);
$html = str_replace('{field}', $radios.$errmsg, $html);
$html = str_replace('{fielddesc}', $row->description, $html);
break;
case 'checkbox':
$errmsg = forme_HTML::«»parseErrorMsg($row->name);
if(isset($_SESSION['formdata'][$row->name])) $row->default_value = str_replace('{checked}','',$row->default_value);
$row->default_value = explode(',',$row->default_value);
$checks = '';
foreach ($row->default_value as $i=>$checkset){
$valTitle = explode('|',$checkset);
if(!isset($valTitle[1])) $valTitle[1] = $valTitle[0];
if(isset($_SESSION['formdata'][$row->name])){
foreach($_SESSION['formdata'][$row->name] as $val){
if($val==$valTitle[0]){
$valTitle[0] = $valTitle[0].'\" checked=\"checked';
}
}
}else{
$valTitle[0] = str_replace('{checked}','\" checked=\"checked',$valTitle[0]);
}
$checks .= '<span class=\"check'.$row->name.'\" style=\"white-space: nowrap\"><input type=\"checkbox\" name=\"form['.$row->name.'][]\" id=\"'. $row->name .$i. '\" value=\"'.$valTitle[0].'\" '.$row->params.' /><label for=\"'. $row->name .$i. '\">'. $valTitle[1].'</label></span>';
}
$html = str_replace('{fieldtitle}',$row->title,$row->fieldstyle);
$html = str_replace('{validationsign}',($row->validation_rule) ? ' *':'',$html);
$html = str_replace('{field}', $checks.$errmsg, $html);
$html = str_replace('{fielddesc}',$row->description,$html);
break;
case 'textarea':
if(isset($_SESSION['formdata'][$row->name])){
$row->default_value = stripslashes($_SESSION['formdata'][$row->name]);
}
$errmsg = forme_HTML::«»parseErrorMsg($row->name);
$html = str_replace('{fieldtitle}',$row->title,$row->fieldstyle);
$html = str_replace('{validationsign}',($row->validation_rule) ? ' *':'',$html);
$html = str_replace('{field}','<textarea name=\"form['.$row->name.']\" id=\"'.$row->name.'\" '.$row->params.'>'.$row->default_value.'</textarea>'.$errmsg,$html);
$html = str_replace('{fielddesc}',$row->description,$html);
break;
case 'select':
$errmsg = forme_HTML::«»parseErrorMsg($row->name);
if(isset($_SESSION['formdata'][$row->name])) $row->default_value = str_replace('{checked}','',$row->default_value);
$options = '';
$row->default_value = explode(',',$row->default_value);
foreach ($row->default_value as $optionset){
$valTitle = explode('|',$optionset);
if(!isset($valTitle[1])) $valTitle[1] = $valTitle[0];
if(isset($_SESSION['formdata'][$row->name])){
foreach($_SESSION['formdata'][$row->name] as $val){
if($val==$valTitle[0]){
$valTitle[0] = $valTitle[0].'\" selected=\"selected';
}
}
}else{
$valTitle[0] = str_replace('{checked}','\" selected=\"selected',$valTitle[0]);
}
$options .= '<option value=\"'.$valTitle[0].'\">'.$valTitle[1].'</option>';
}
$html = str_replace('{fieldtitle}',$row->title,$row->fieldstyle);
$html = str_replace('{validationsign}',($row->validation_rule) ? ' *':'',$html);
$html = str_replace('{field}','<select name=\"form['.$row->name.'][]\" '.$row->params.' id=\"'.$row->name.'\" >'.$options.'</select>'.$errmsg,$html);
$html = str_replace('{fielddesc}',$row->description,$html);
break;
case 'calendar':
if(isset($_SESSION['formdata'][$row->name])){
$default_value = $_SESSION['formdata'][$row->name];
}else{
$default_value = '';
}
$errmsg = forme_HTML::«»parseErrorMsg($row->name);
$html = str_replace('{fieldtitle}',$row->title,$row->fieldstyle);
$html = str_replace('{validationsign}',($row->validation_rule) ? ' *':'',$html);
echo JHTML::_('calendar', \"\", $row->name, txt.$row->name);
$html = str_replace('{field}','<div id=\"'.$row->name.'Container\"></div><input id=\"txt'.$row->name.'\" name=\"form['.$row->name.']\" value=\"'.$default_value.'\" type=\"hidden\"/>'.$errmsg,$html);
$html = str_replace('{fielddesc}',$row->description,$html);
break;
case 'free text':
$html = str_replace('{fieldtitle}',$row->title,$row->fieldstyle);
$html = str_replace('{validationsign}','',$html);
$html = str_replace('{field}',$row->default_value,$html);
$html = str_replace('{fielddesc}',$row->description,$html);
break;
case 'ticket number':
$length = (int)$row->default_value;
if($length<1||$length>255) $length = 8;
$key = \"\";
$possible = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\";
$i = 0;
while ($i < $length) {
$key .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
$i++;
}
$html = str_replace('{fieldtitle}',$row->title,$row->fieldstyle);
$html = str_replace('{validationsign}','',$html);
$html = str_replace('{field}','<input id=\"'.$row->name.'\" name=\"form['.$row->name.']\" value=\"'.$key.'\" type=\"hidden\"/>',$html);
$html = str_replace('{fielddesc}',$row->description,$html);
break;
case 'captcha':
$errmsg = forme_HTML::«»parseErrorMsg($row->name);
$html = str_replace('{fieldtitle}',$row->title,$row->fieldstyle);
$html = str_replace('{validationsign}',($row->validation_rule) ? ' *':'',$html);
$html = str_replace('{field}','<img src=\"'.JURI :: base().'index.php?option=com_forme&func=captcha\"/><br/><input type=\"text\" name=\"form['.$row->name.']\" value=\"'.$row->default_value.'\" id=\"'.$row->name.'\" '.$row->params.' style=\"width:74px;text-align:center;\" />'.$errmsg,$html);
$html = str_replace('{fielddesc}',$row->description,$html);
break;
}
return $html;
}
//end of class
}
?> <br><br>Post edited by: latristesse, at: 2008/04/15 05:44
|