Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hipig opened this issue Apr 28, 2019 · 6 comments
Open

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

hipig opened this issue Apr 28, 2019 · 6 comments

Comments

@hipig
Copy link

hipig commented Apr 28, 2019

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

@codingyu
Copy link
Member

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

@hipig
Copy link
Author

hipig commented Apr 28, 2019

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

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

@codingyu
Copy link
Member

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

@YKAEJ
Copy link

YKAEJ commented Oct 14, 2019

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

@hipig
Copy link
Author

hipig commented Oct 15, 2019

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

@Fanxd
Copy link

Fanxd commented Mar 11, 2020

@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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants