fix rendering content of option form
This commit is contained in:
parent
2bff6a080f
commit
325ea187e0
|
|
@ -45,7 +45,7 @@ class AdminController extends Controller
|
|||
|
||||
$form->group('max_upload_file_size', '最大允许上传大小', function($group) {
|
||||
// main textbox
|
||||
$group->text('max_upload_file_size', option('max_upload_file_size'));
|
||||
$group->text('max_upload_file_size');
|
||||
$group->addon('KB');
|
||||
})->hint('PHP 限制:'.ini_get('post_max_size').',定义在 php.ini 中。');
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ class AdminController extends Controller
|
|||
|
||||
$form->checkbox('auto_del_invalid_texture', '失效材质', '自动删除失效材质')->hint('自动从皮肤库中删除文件不存在的材质记录');
|
||||
|
||||
$form->textarea('comment_script', '评论代码', option('comment_script'), function($textarea) {
|
||||
$form->textarea('comment_script', '评论代码', function($textarea) {
|
||||
$textarea->setRows(6);
|
||||
$textarea->setDescription('评论代码内可使用占位符,<code>{tid}</code> 将会被自动替换为材质的 id,<code>{name}</code> 会被替换为材质名称,<code>{url}</code> 会被替换为当前页面地址。');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -51,11 +51,11 @@ class OptionForm
|
|||
return $select;
|
||||
}
|
||||
|
||||
public function textarea($id, $name, $value, $callback)
|
||||
public function textarea($id, $name, $callback)
|
||||
{
|
||||
$item = $this->addItem('textarea', $id, $name);
|
||||
|
||||
$textarea = new OptionFormTextarea($id, $value);
|
||||
$textarea = new OptionFormTextarea($id);
|
||||
|
||||
call_user_func($callback, $textarea);
|
||||
|
||||
|
|
@ -119,7 +119,7 @@ class OptionForm
|
|||
}
|
||||
}
|
||||
|
||||
$this->success = true;
|
||||
session()->flash($this->id.'.status', 'success');
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
@ -282,10 +282,14 @@ class OptionFormTextarea
|
|||
|
||||
protected $description = "";
|
||||
|
||||
public function __construct($id, $value)
|
||||
public function __construct($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->value = $value;
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function setContent($content)
|
||||
{
|
||||
$this->value = $content;
|
||||
}
|
||||
|
||||
public function setRows($rows)
|
||||
|
|
@ -300,6 +304,10 @@ class OptionFormTextarea
|
|||
|
||||
public function render()
|
||||
{
|
||||
if (is_null($this->value)) {
|
||||
$this->value = option($this->id);
|
||||
}
|
||||
|
||||
return view('vendor.option-form.textarea')->with([
|
||||
'rows' => $this->rows,
|
||||
'id' => $this->id,
|
||||
|
|
@ -320,18 +328,28 @@ class OptionFormGroup
|
|||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function text($id, $value)
|
||||
public function text($id, $value = null)
|
||||
{
|
||||
$this->items[] = view('vendor.option-form.text')->withId($id)->withValue($value);
|
||||
$this->items[] = ['type' => 'text', 'id' => $id, 'value' => $value];
|
||||
}
|
||||
|
||||
public function addon($value)
|
||||
{
|
||||
$this->items[] = view('vendor.option-form.addon')->withValue($value);
|
||||
$this->items[] = ['type' => 'addon', 'id' => null, 'value' => $value];
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('vendor.option-form.group')->with('items', $this->items);
|
||||
$rendered = [];
|
||||
|
||||
foreach ($this->items as $item) {
|
||||
if ($item['id'] && !$item['value']) {
|
||||
$item['value'] = option($item['id']);
|
||||
}
|
||||
|
||||
$rendered[] = view('vendor.option-form.'.$item['type'])->withId($item['id'])->withValue($item['value']);
|
||||
}
|
||||
|
||||
return view('vendor.option-form.group')->with('items', $rendered);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
resources/views/vendor/option-form/main.tpl
vendored
2
resources/views/vendor/option-form/main.tpl
vendored
|
|
@ -5,7 +5,7 @@
|
|||
<form method="post">
|
||||
<input type="hidden" name="option" value="{{ $id }}">
|
||||
<div class="box-body">
|
||||
@if ($success)
|
||||
@if (session("$id.status") == 'success')
|
||||
<div class="callout callout-success">设置已保存。</div>
|
||||
@endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user