mirror of https://gitee.com/karson/fastadmin.git
一键生成CRUD生成紧凑型表单
parent
8ecb59db9a
commit
d2e55530cb
|
|
@ -580,6 +580,7 @@ class Crud extends Command
|
|||
$formEditElement = $this->getReplacedStub('html/select', ['field' => $field, 'fieldName' => $fieldName, 'fieldList' => $this->getFieldListName($field), 'attrStr' => Form::attributes($attrArr), 'selectedValue' => "\$row.{$field}"]);
|
||||
} elseif ($inputType == 'datetime') {
|
||||
$cssClassArr[] = 'datetimepicker';
|
||||
$attrArr['placeholder'] = "{:__('Please select')}{:__('{$langField}')}";
|
||||
$attrArr['class'] = implode(' ', $cssClassArr);
|
||||
$format = "YYYY-MM-DD HH:mm:ss";
|
||||
$phpFormat = "Y-m-d H:i:s";
|
||||
|
|
@ -636,6 +637,7 @@ class Crud extends Command
|
|||
$formEditElement = $this->getReplacedStub('html/' . $inputType, ['field' => $field, 'fieldName' => $fieldName, 'fieldList' => $this->getFieldListName($field), 'attrStr' => Form::attributes($attrArr), 'selectedValue' => "\$row.{$field}"]);
|
||||
} elseif ($inputType == 'textarea') {
|
||||
$cssClassArr[] = $this->isMatchSuffix($field, $this->editorSuffix) ? $this->editorClass : '';
|
||||
$attrArr['placeholder'] = "{:__('Please input')}{:__('{$langField}')}";
|
||||
$attrArr['class'] = implode(' ', $cssClassArr);
|
||||
$attrArr['rows'] = 5;
|
||||
$formAddElement = Form::textarea($fieldName, $defaultValue, $attrArr);
|
||||
|
|
@ -656,17 +658,20 @@ class Crud extends Command
|
|||
$formAddElement = $this->getReplacedStub('html/' . $inputType, ['field' => $field, 'fieldName' => $fieldName, 'fieldYes' => $yes, 'fieldNo' => $no, 'attrStr' => Form::attributes($attrArr), 'fieldValue' => $defaultValue, 'fieldSwitchClass' => $defaultValue == $no ? $stateNoClass : '']);
|
||||
$formEditElement = $this->getReplacedStub('html/' . $inputType, ['field' => $field, 'fieldName' => $fieldName, 'fieldYes' => $yes, 'fieldNo' => $no, 'attrStr' => Form::attributes($attrArr), 'fieldValue' => "{\$row.{$field}}", 'fieldSwitchClass' => "{eq name=\"\$row.{$field}\" value=\"{$no}\"}fa-flip-horizontal text-gray{/eq}"]);
|
||||
} elseif ($inputType == 'citypicker') {
|
||||
$attrArr['placeholder'] = "{:__('Please select')}{:__('{$langField}')}";
|
||||
$attrArr['class'] = implode(' ', $cssClassArr);
|
||||
$attrArr['data-toggle'] = "city-picker";
|
||||
$formAddElement = sprintf("<div class='control-relative'>%s</div>", Form::input('text', $fieldName, $defaultValue, $attrArr));
|
||||
$formEditElement = sprintf("<div class='control-relative'>%s</div>", Form::input('text', $fieldName, $editValue, $attrArr));
|
||||
} else {
|
||||
$attrArr['placeholder'] = "{:__('Please input')}{:__('{$langField}')}";
|
||||
$search = $replace = '';
|
||||
//特殊字段为关联搜索
|
||||
if ($this->isMatchSuffix($field, $this->selectpageSuffix)) {
|
||||
$inputType = 'text';
|
||||
$defaultValue = '';
|
||||
$attrArr['data-rule'] = 'required';
|
||||
$attrArr['placeholder'] = "{:__('Please select')}{:__('{$langField}')}";
|
||||
$cssClassArr[] = 'selectpage';
|
||||
$selectpageController = str_replace('_', '/', substr($field, 0, strripos($field, '_')));
|
||||
$attrArr['data-source'] = $selectpageController . "/index";
|
||||
|
|
@ -1310,8 +1315,8 @@ EOD;
|
|||
$langField = mb_ucfirst($field);
|
||||
return <<<EOD
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('{$langField}')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<label for="c-{$field}" class="control-label">{:__('{$langField}')}:</label>
|
||||
<div class="pp_container">
|
||||
{$content}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1337,11 +1342,11 @@ EOD;
|
|||
return <<<EOD
|
||||
<div class="input-group">
|
||||
{$content}
|
||||
<span class="msg-box n-top" for="c-{$field}"></span>
|
||||
<div class="input-group-addon no-border no-padding">
|
||||
<span><button type="button" id="plupload-{$field}" class="btn btn-danger plupload" data-input-id="c-{$field}"{$uploadfilter}{$multiple}{$preview}><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
|
||||
<span><button type="button" id="fachoose-{$field}" class="btn btn-primary fachoose" data-input-id="c-{$field}"{$selectfilter}{$multiple}><i class="fa fa-list"></i> {:__('Choose')}</button></span>
|
||||
</div>
|
||||
<span class="msg-box n-right" for="c-{$field}"></span>
|
||||
</div>
|
||||
{$previewcontainer}
|
||||
EOD;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
|
||||
<form id="add-form" role="form" data-toggle="validator" method="POST" action="">
|
||||
{%addList%}
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="pp_container text-center">
|
||||
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
|
||||
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use app\common\controller\Backend;
|
|||
*/
|
||||
class {%controllerName%} extends Backend
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* {%modelName%}模型对象
|
||||
* @var \{%modelNamespace%}\{%modelName%}
|
||||
|
|
@ -24,7 +24,7 @@ class {%controllerName%} extends Backend
|
|||
$this->model = new \{%modelNamespace%}\{%modelName%};
|
||||
{%controllerAssignList%}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
|
||||
<form id="edit-form" role="form" data-toggle="validator" method="POST" action="">
|
||||
{%editList%}
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="pp_container text-center">
|
||||
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
|
||||
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
<div class="radio">
|
||||
<div class="radio" id="c-{%field%}">
|
||||
{foreach name="{%fieldList%}" item="vo"}
|
||||
<label for="{%fieldName%}-{$key}"><input id="{%fieldName%}-{$key}" name="{%fieldName%}" type="radio" value="{$key}" {in name="key" value="{%selectedValue%}"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
<select {%attrStr%}>
|
||||
<select {%attrStr%}>
|
||||
{foreach name="{%fieldList%}" item="vo"}
|
||||
<option value="{$key}" {in name="key" value="{%selectedValue%}"}selected{/in}>{$vo}</option>
|
||||
{/foreach}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
public function {%methodName%}($value, $data)
|
||||
{
|
||||
{
|
||||
$value = $value ? $value : (isset($data['{%field%}']) ? $data['{%field%}'] : '');
|
||||
$list = $this->{%listMethodName%}();
|
||||
return isset($list[$value]) ? $list[$value] : '';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
public function {%methodName%}($value, $data)
|
||||
{
|
||||
{
|
||||
$value = $value ? $value : (isset($data['{%field%}']) ? $data['{%field%}'] : '');
|
||||
$list = $this->{%listMethodName%}();
|
||||
return isset($list[$value]) ? $list[$value] : '';
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class {%modelName%} extends Model
|
|||
|
||||
// 表名
|
||||
protected ${%modelTableType%} = '{%modelTableTypeName%}';
|
||||
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = {%modelAutoWriteTimestamp%};
|
||||
|
||||
|
|
@ -25,9 +25,9 @@ class {%modelName%} extends Model
|
|||
protected $append = [
|
||||
{%appendAttrList%}
|
||||
];
|
||||
|
||||
|
||||
{%modelInit%}
|
||||
|
||||
|
||||
{%getEnumList%}
|
||||
|
||||
{%getAttrList%}
|
||||
|
|
|
|||
|
|
@ -114,9 +114,16 @@ html.ios-fix body {
|
|||
table.table-template {
|
||||
overflow: hidden;
|
||||
}
|
||||
.sp_container .msg-box {
|
||||
.pp_container {
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.sp_container .msg-box,.pp_container .msg-box {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
.toast-top-right-index {
|
||||
|
|
@ -989,6 +996,40 @@ table.table-nowrap thead > tr > th {
|
|||
.wipecache li a {
|
||||
color: #444444 !important;
|
||||
}
|
||||
|
||||
.col-md-1-5 {
|
||||
width: 20% !important;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.col-xs-1-5,.col-sm-1-5,.col-md-1-5,.col-lg-1-5 {
|
||||
min-height: 1px;
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.col-sm-1-5 {
|
||||
width: 20%;
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 992px) {
|
||||
.col-md-1-5 {
|
||||
width: 20%;
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1200px) {
|
||||
.col-lg-1-5 {
|
||||
width: 20%;
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
|
||||
div.pre {
|
||||
display: block;
|
||||
padding: 5px;
|
||||
|
|
@ -1003,6 +1044,11 @@ div.pre {
|
|||
border-radius: 3px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#add-form .panel-body,#edit-form .panel-body{
|
||||
padding-bottom:0;
|
||||
}
|
||||
|
||||
/*修正开关关闭下的颜色值*/
|
||||
.btn-switcher.disabled {
|
||||
opacity: .6;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -9290,8 +9290,9 @@ define('form',['jquery', 'bootstrap', 'upload', 'validator'], function ($, undef
|
|||
validClass: 'has-success',
|
||||
invalidClass: 'has-error',
|
||||
bindClassTo: '.form-group',
|
||||
formClass: 'n-default n-bootstrap',
|
||||
msgClass: 'n-right',
|
||||
formClass: 'n-yellow n-bootstrap',
|
||||
msgClass: 'n-top',
|
||||
theme: 'yellow_top',
|
||||
stopOnError: true,
|
||||
display: function (elem) {
|
||||
return $(elem).closest('.form-group').find(".control-label").text().replace(/\:/, '');
|
||||
|
|
|
|||
|
|
@ -12,8 +12,9 @@ define(['jquery', 'bootstrap', 'upload', 'validator'], function ($, undefined, U
|
|||
validClass: 'has-success',
|
||||
invalidClass: 'has-error',
|
||||
bindClassTo: '.form-group',
|
||||
formClass: 'n-default n-bootstrap',
|
||||
msgClass: 'n-right',
|
||||
formClass: 'n-yellow n-bootstrap',
|
||||
msgClass: 'n-top',
|
||||
theme: 'yellow_top',
|
||||
stopOnError: true,
|
||||
display: function (elem) {
|
||||
return $(elem).closest('.form-group').find(".control-label").text().replace(/\:/, '');
|
||||
|
|
|
|||
Loading…
Reference in New Issue