为FormBuilder中的fieldlist增加table布局支持

pull/157/head
Oo小刚oO 2019-11-28 11:09:47 +08:00
parent 1ee56b58fd
commit fd77788013
1 changed files with 22 additions and 4 deletions

View File

@ -666,11 +666,28 @@ EOD;
if (is_null($title)) {
$title = [__('Key'), __('Value')];
}
$ins = implode("\n", array_map(function ($value) {
return "<ins>{$value}</ins>";
}, $title));
$value = is_array($value) ? json_encode($value) : $value;
$html = <<<EOD
if (isset($options['data-layout']) && $options['data-layout'] == 'table') {
$th = implode("\n", array_map(function ($value) {
return "<th>{$value}</th>";
}, $title));
$html = <<<EOD
<dl class="fieldlist" data-name="{$name}" {$template} {$attributes}>
<table class="table table-bordered table-condensed">
<tr>
{$th}
<th>操作</th>
</tr>
</table>
<a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {$append}</a>
<textarea name="{$name}" class="form-control hide" cols="30" rows="5">{$value}</textarea>
</dl>
EOD;
}else{
$ins = implode("\n", array_map(function ($value) {
return "<ins>{$value}</ins>";
}, $title));
$html = <<<EOD
<dl class="fieldlist" data-name="{$name}" {$template} {$attributes}>
<dd>
{$ins}
@ -679,6 +696,7 @@ EOD;
<textarea name="{$name}" class="form-control hide" cols="30" rows="5">{$value}</textarea>
</dl>
EOD;
}
return $html;
}