首页 > CMS > 织梦DEDE > 正文

dedecms自定义表单提交联动类型只显示枚举值的解决办法

2024-07-12 09:13:03
字体:
来源:转载
供稿:网友
大家在解决织梦后台无法添加显示联动选项后,发现提交表单后,后台枚举值只显示数字。下面我们就来解决这个问题,让提交到后台的数据显示文字。
 
下面是修改方法:
 
1.在"后台目录"/templets/diy_list.htm找到如下代码:
 
else if($fielddata[1]=='addon'){$fields[$field] = "<a href='{$fields[$field]}' target='_blank'><img src='images/channeladd.gif' border='0' /> 其它附件</a>";}
 
在下面加入:
 
//联动类型显示修正开始 else if($fielddata[1]=='stepselect') { $db->Execute('me',"SELECT * FROM `dede_stepselect` WHERE itemname='{$fielddata[0]}'"); while($arr = $db->GetArray(me)) { $egroup = $arr['egroup']; } $fields[$field] = Getenums("{$fields[$field]}",$egroup); } 

2.继续这个文件向下找到:
 
{/dede:datalist}
 
在下面加入:

<?phpfunction Getenums($evalue=0,$egroup){if( !isset($GLOBALS['em_'.$egroup.'s']) ){$cachefile = DEDEDATA.'/enums/'.$egroup.'.php';if(!file_exists($cachefile)){require_once(DEDEINC.'/enums.func.php');WriteEnumsCache();}if(!file_exists($cachefile)){return '';}else{require_once($cachefile);}}if($evalue>=500){if($evalue % 500 == 0){return (isset($GLOBALS['em_'.$egroup.'s'][$evalue]) ? $GLOBALS['em_'.$egroup.'s'][$evalue] : '');}else if (preg_match("#([0-9]{1,})/.([0-9]{1,})#", $evalue, $matchs)){$esonvalue = $matchs[1];$etopvalue = $esonvalue - ($esonvalue % 500);$esecvalue = str_replace(".00",".",$evalue);$GLOBALS['em_'.$egroup.'s'][$etopvalue] = empty($GLOBALS['em_'.$egroup.'s'][$etopvalue])? '': $GLOBALS['em_'.$egroup.'s'][$etopvalue];$GLOBALS['em_'.$egroup.'s'][$esonvalue] = empty($GLOBALS['em_'.$egroup.'s'][$esonvalue])? '': $GLOBALS['em_'.$egroup.'s'][$esonvalue];$GLOBALS['em_'.$egroup.'s'][$esecvalue] = empty($GLOBALS['em_'.$egroup.'s'][$esecvalue])? '': $GLOBALS['em_'.$egroup.'s'][$esecvalue];return $GLOBALS['em_'.$egroup.'s'][$etopvalue].' - '.$GLOBALS['em_'.$egroup.'s'][$esonvalue].' - '.$GLOBALS['em_'.$egroup.'s'][$esecvalue];}else{$elimit = $evalue % 500;$erevalue = $evalue - $elimit;$GLOBALS['em_'.$egroup.'s'][$erevalue] = empty($GLOBALS['em_'.$egroup.'s'][$erevalue])? '': $GLOBALS['em_'.$egroup.'s'][$erevalue];$GLOBALS['em_'.$egroup.'s'][$evalue] = empty($GLOBALS['em_'.$egroup.'s'][$evalue])? '': $GLOBALS['em_'.$egroup.'s'][$evalue];return $GLOBALS['em_'.$egroup.'s'][$erevalue].' - '.$GLOBALS['em_'.$egroup.'s'][$evalue];}}}?>


修改后,再去提交数据试试。发现就会显示文字了!
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表