联系官方销售客服
1835022288
028-61286886
结合LayUI中的时间组件和Ftable字段去二开,新增时间选择字段,有可能会对其他人有用,就分享一下,代码回复就可以看到
private function _field_type_select($id, $type) { $arr = [ 0 => dr_lang('不使用'), 1 => dr_lang('文本框'), 2 => dr_lang('下拉选择框'), 3 => dr_lang('时间日期'), ]; $html = '<select class="form-control" name="data[setting][option][field]['.$id.'][type]">'; foreach ($arr as $i => $name) { $html.= '<option '.($i == $type ? 'selected' : '').' value="'.$i.'">'.$name.'</option>'; } $html.= '</select>'; return $html; } private function _field_type_html($config, $cname, $value, $hang, $lie) { $html = ''; if ($config['type'] == 1) { $html.= '<label><input type="text" class="form-control" name="data['.$cname.']['.$hang.']['.$lie.']" value="'.$value[$hang][$lie].'"></label>'; } elseif ($config['type'] == 2) { $html = '<label><select class="form-control" name="data['.$cname.']['.$hang.']['.$lie.']">'; $arr = explode(',', $config['option']); foreach ($arr as $name) { $html.= '<option '.($value[$hang][$lie] == $name ? 'selected' : '').' value="'.$name.'">'.$name.'</option>'; } $html.= '</select></label>'; }elseif ($config['type'] == 3) { $html = ' <link href="'.ROOT_THEME_PATH.'layui/css/layui.css" rel="stylesheet" type="text/css" /> <link href="'.ROOT_THEME_PATH.'layui/css/modules/laydate/default/laydate.css?v=5.0.9" rel="stylesheet" type="text/css" /> <div class="layui-form"> <div class="layui-form-item"> <div class="layui-inline"> <div class="layui-input-inline"> <input type="text" class="layui-input timeSelect" value="'.$value[$hang][$lie].'" name="data['.$cname.']['.$hang.']['.$lie.']" placeholder="yyyy-MM-dd"> </div> </div> </div> </div> <script src="'.ROOT_THEME_PATH.'layui/layui.js" type="text/javascript"></script> <script src="'.ROOT_THEME_PATH.'layui/lay/modules/laydate.js" type="text/javascript"></script> <script> layui.use("laydate", function(){ var laydate = layui.laydate; lay(".timeSelect").each(function(){ laydate.render({ elem: this, theme: "grid" }); }); }); </script> '; } return $html; }