laravel-admin-extensions / UEditor

UEditor extension for laravel-admin
MIT License
62 stars 17 forks source link

一对多内使用该扩展不能正常使用 #7

Open hipig opened 5 years ago

hipig commented 5 years ago

查源码发现,编辑器是在id上加载的,而一对多内所有的name都是一样的,例如字段名为content,id则为content,所以所有的id也是一样,故只会渲染第一个id为name编辑器

codingyu commented 5 years ago

是的,受限于 Laravel-admin 这里好像不是很容易判断是否为一对多,晚点我研究一下,欢迎 PR

hipig commented 5 years ago

是的,受限于 Laravel-admin 这里好像不是很容易判断是否为一对多,晚点我研究一下,欢迎 PR

貌似name是唯一的,是否可以把这个当做成id

codingyu commented 5 years ago

@pigzzz123 可以使用 name ,但在一对多点击添加的时候还是有点问题

YKAEJ commented 5 years ago

遇到这个问题,请问有什么解决方案么

hipig commented 5 years ago

@YKAEJ 暂时没有找到合适的解决办法,已经弃用了

Fanxd commented 4 years ago

@hipig @codingyu @YKAEJ 搞定了,但是改的是底层文件,不是很有友好的操作。

// vendor\codingyu\ueditor\src
$this->script = <<<EOT
var laKey = "{$this->elementName}";
window.UEDITOR_CONFIG.serverUrl = '{$laravel_ueditor_route}';

if (laKey == 'body[new___LA_KEY__][body]') {
    laKey = 'body[new_'+index+'][body]';
}
    console.log(laKey);
UE.delEditor(laKey);

var ue_{$jsId} = UE.getEditor(laKey, {$config});
ue_{$jsId}.ready(function() {
    ue_{$jsId}.execCommand('serverparam', '_token', '$token');
});

EOT;
// vendor\codingyu\ueditor\resources\views\editor.blade.php
<div class="{{$viewClass['form-group']}} {!! !$errors->has($errorKey) ? '' : 'has-error' !!}">

    <label for="{{$id}}" class="{{$viewClass['label']}} control-label">{{$label}}</label>

    <div class="{{$viewClass['field']}}">

        @include('admin::form.error')

        <textarea id="{{$name}}" name="{{$name}}">{!! old($column, $value) !!}</textarea>

        @include('admin::form.help-block')

    </div>
</div>