编程爱好者之家
1.先下载ueditor解压后放在/public/packages/目录下;然后新建扩展文件app/Admin/Extensions/Form/UEditor.php
<?php
namespace App\Admin\Extensions\Form;
use Encore\Admin\Form\Field;
class UEditor extends Field
{
protected static $css = [
];
public static $isJs=false;
protected static $js = [
'/packages/ueditor/ueditor.config.js',
'/packages/ueditor/ueditor.all.min.js',
'/packages/ueditor/lang/zh-cn/zh-cn.js',
];
protected $view = 'admin.ueditor';
public function render()
{
$this->script = <<<EOT
UE.delEditor('{$this->id}');
var ue = UE.getEditor('{$this->id}');
EOT;
return parent::render();
}
}2.新建view resources/views/admin/UEditor.blade.php:
<div class="form-group {!! !$errors->has($errorKey) ?: 'has-error' !!}">
<label for="{{$id}}" class="col-sm-2 control-label">{{$label}}</label>
<div class="col-sm-8">
@include('admin::form.error')
<textarea class="{{ $class }}" id="{{$name}}" name="{{$name}}" placeholder="{{ $placeholder }}" {!! $attributes !!} >{{ old($column, $value) }}</textarea>
@include('admin::form.help-block')
</div>
</div>3.然后在app/Admin/bootstrap.php中引入扩展:
use App\Admin\Extensions\Form\UEditor;
use Encore\Admin\Form;
Form::extend('ueditor', UEditor::class);4.然后就能在form中使用了:
$form->ueditor('content');