When I use hasMany + try to load ckeditor, he does not load properly.
$form->tab($lang['name'], function ($form) use($key, $lang) {
$form->hasMany('trans' . $key, function (Form\NestedForm $form) use($key, $lang) {
$form->text('title', 'Title ');
$form->text('meta_t', 'Meta Title');
$form->text('meta_d', 'Meta Description');
$form->ckeditor('text');
});
});
HTML:
<textarea class="form-control transen text" id="text" name="transen[3][text]" placeholder="Input Text" >en текст</textarea>
JS init:
$('textarea.transen text').ckeditor();
But should be:
$('textarea.transen').ckeditor();
Or:
$('textarea.transen #text').ckeditor();
And id="text" should be unique
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
For this problem, I implemented a solution in my code. I edited render() function in app/Admin/Extensions/Form/CKEditor.php
public function render()
{
$class = explode(' ', $this->getElementClassString())[0];
$this->script = "$('textarea.{$class}').ckeditor();";
return parent::render();
}
App\Admin\Extensions\Form\CKEditor.php
<?php
namespace App\Admin\Extensions\Form;
use Encore\Admin\Form\Field;
class CKEditor extends Field
{
public static $js = [
'vendor/laravel-admin-ext/ckeditor/ckeditor.js',
'vendor/laravel-admin-ext/ckeditor/adapters/jquery.js',
];
protected $view = 'admin.ckeditor';
public function render()
{
$class = explode(' ', $this->getElementClassString())[0];
$this->script = "$('textarea.{$class}').ckeditor();";
return parent::render();
}
}
App\Admin\bootstrap.php:
use App\Admin\Extensions\Form\CKEditor;
.....
Encore\Admin\Form::extend('ckeditor', CKEditor::class);
resources\views\admin\ckeditor.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="form-control {{ $class }}" name="{{$name}}" placeholder="{{ $placeholder }} ckeditor_class" {!! $attributes !!} >{{ old($column, $value) }}</textarea>
@include('admin::form.help-block')
</div>
</div>
Most helpful comment
For this problem, I implemented a solution in my code. I edited render() function in app/Admin/Extensions/Form/CKEditor.php