管理员
站长QQ:515138
- 主题
- 124
- 回帖
- 7
- 在线时间
- 76 小时
- 注册时间
- 2024-2-3
- 最后登录
- 2024-11-14
|
thinkphp8模板前端自定义字段调用显示代码分享,支持各种表单类型的输出
- <!--自定义字段内容 1输入框,2单选,3复选框,4下拉菜单,5文本域,6文件,7浮点,8整型,9长文本longtextstar-->
- <?php foreach($diyfields as $ke=>$v):?>
- <div class="layui-form-item" pane>
- <label class="layui-form-label">{$v['field_cname']}</label>
- <div class="layui-input-block">
- <?php switch ($v['field_type']){
- case 1:
- case 7:
- case 8:
- echo "<input type='text' name='".$v['field_ename']."' placeholder='请输入' class='layui-input'>";
- break;
- case 5:
- echo "<textarea placeholder='请输入内容' name='".$v['field_ename']."' class='layui-textarea'></textarea>";
- break;
- case 2:
- if($v['field_values']){
- $arr = explode(',',$v['field_values']);
- foreach($arr as $k1 => $v1){
- echo "<input type='radio' name='".$v['field_ename']."' value='".$v1."'";
- if($k1 == 0){echo "checked ";}
- echo "title='".$v1."'>";
- }
- }
- break;
- case 3:
- if($v['field_values']){
- $arr = explode(',',$v['field_values']);
- foreach($arr as $k1 => $v1){
- echo "<input type='checkbox' name='".$v['field_ename']."[]' value='".$v1."'";
- if($k1 == 0){echo "checked ";}
- echo "title='".$v1."'>";
- }
- }
- break;
- case 4:
- if($v['field_values']){
- $arr = explode(',',$v['field_values']);
- echo "<select name='".$v['field_ename']."'>";
- foreach($arr as $k1 => $v1){
- echo "<option value='{$k1}' ";
- if($k1 == 0){echo "selected ";}
- echo ">".$v1."</option>";
- }
- echo "</select>";
- }
- break;
- case 9:
- echo get_ueditor($v['field_ename'],"../system.files/bian?act=cms_archives_jhadd_bian_".$v['field_ename']."");
- break;
- default:
- echo "<input type='text' name='".$v['field_ename']."' placeholder='请输入' class='layui-input'>";
- break;
- }
- ?>
- </div>
- </div>
- <?php endforeach;?>
- <!--自定义字段内容 end-->
复制代码
|
|