yii2-dynamicform icon indicating copy to clipboard operation
yii2-dynamicform copied to clipboard

How to add text editor widget (e.g. CKEditor) to dynamicform?

Open kavasey opened this issue 6 years ago • 6 comments

Hi. Thank you for your excellent extention. I have tried to integrate text editor using yii2-dynamicform but to no avail. I tried tinyMce(https://github.com/2amigos/yii2-tinymce-widget) but no success (first item does not get initialized thus display a textarea).

Then I tried https://github.com/2amigos/yii2-ckeditor-widget which had the first row initialized. subsequent rows don't get initialized.

I have the following as the snippet inside the widget foreach loop.

<?= $form->field($modelBlock, "[{$i}]description")->widget(CKEditor::className(), [ 'options' => ['rows' => 3], 'preset' => 'basic' ]); ?>

Any help or pointers would be appreciated.

Thank you.

kavasey avatar May 16 '18 12:05 kavasey

I have found a better maintained fork here. Since this repo looks like abandoned, then I suggest you try asking the same question there.

mtangoo avatar May 16 '18 13:05 mtangoo

@mtangoo Thanks for the mention. I'll check it out.

kavasey avatar May 19 '18 18:05 kavasey

@mtangoo Thankyou

moysoft avatar Jun 21 '19 01:06 moysoft

@moysoft you are welcome!

mtangoo avatar Jun 21 '19 08:06 mtangoo

Hello,

Try this solution

jQuery(".dynamicform_wrapper").on("afterInsert", function(e, item) {
    tinyMCE.init({selector: 'textarea'});
});
jQuery(".dynamicform_wrapper").on("afterDelete", function(e) {
    tinyMCE.remove();
    tinyMCE.init({selector: 'textarea'});
});

fakname8 avatar Sep 04 '19 13:09 fakname8

@kavasey Is it working in the suggested repo?

poonga avatar Mar 26 '23 10:03 poonga