使用CKEditor 5保存多个文本区域

时间:2018-11-16 13:55:46

标签: php jquery ckeditor phalcon

我将CKEditor 5设置为多个,所有编辑器都显示正常,但是只有第一个可以保存在db上。

我更改每个文本区域的名称。第一个是line [0] [descSoftware],第二个是line [1] [descSoftware],等等。

当我写var_dump($ _ POST);在形式上。下一个数组(descSoftware)不会为我带来任何字符串:

array(2) {
["nameSoftware"]=>
string(4) "Test"
["soft"]=>
array(2) {
[0]=>
array(3) {
["typeSoftware"]=>
string(4) "test"
["versionSoftware"]=>
string(1) "1"
["descSoftware"]=>
string(12) "
test1
"
}
[1]=>
array(3) {
["typeSoftware"]=>
string(5) "test2"
["versionSoftware"]=>
string(1) "2"
["descSoftware"]=>
string(0) ""
}
}
}

我的观点是php,我正在使用Phalcon作为框架:

$formSoftwares .= $this->tag->tagHtmlClose('br');
            $formSoftwares .= $this->tag->tagHtml('div',['class' => 'col-xs-12']);
            $formSoftwares .= $this->tag->tagHtml('h4', ['class' => 'box-title']);
            $formSoftwares .= 'Versão Nº: ';
            $formSoftwares .= $this->tag->tagHtml('span', ['class' => 'line']);
            $formSoftwares .= $this->tag->tagHtmlClose('span');
            $formSoftwares .= $this->tag->tagHtmlClose('h4');
            $formSoftwares .= $this->tag->tagHtmlClose('div');
            //Campo tipo do software
            $formSoftwares .= $this->tag->tagHtml('div',['class' => 'col-xs-4']);
            $formSoftwares .= $this->tag->tagHtml('label', ['for' => 'typeSoftware']);
            $formSoftwares .= 'Tipo de software:';
            $formSoftwares .= $this->tag->tagHtmlClose('label');
            $formSoftwares .= $form->render('typeSoftware',['name' => 'soft[0][typeSoftware]', 'require' => '']);
            $formSoftwares .= $this->tag->tagHtmlClose('div');
            //Campo Versão do software
            $formSoftwares .= $this->tag->tagHtml('div',['class' => 'col-xs-4']);
            $formSoftwares .= $this->tag->tagHtml('label', ['for' => 'versionSoftware']);
            $formSoftwares .= 'Versão do Software:';
            $formSoftwares .= $this->tag->tagHtmlClose('label');
            $formSoftwares .= $form->render('versionSoftware',['name' => 'soft[0][versionSoftware]', 'require' => '']);
            $formSoftwares .= $this->tag->tagHtmlClose('div');
            //botões add e remove
            $formSoftwares .= $this->tag->tagHtml('div',['class' => 'col-xs-4']);
            $formSoftwares .= $this->tag->tagHtml('button',['style' => 'margin-top: 21px;font-size: 15px', 'type' => 'button', 'class' => 'btn btn-primary addSoftware', 'id' => 'addSoftware']);
            //$formSoftwares .= '+';
            $formSoftwares .= $this->tag->tagHtml('i', ['class' => 'fa fa-plus']);
            $formSoftwares .= $this->tag->tagHtmlClose('i');
            $formSoftwares .= $this->tag->tagHtmlClose('button');
            $formSoftwares .= $this->tag->tagHtmlClose('div');
            // Campo descrição
            $formSoftwares .= $this->tag->tagHtml('div',['class' => 'col-xs-12', 'style' => 'margin-top: 15px']);
            $formSoftwares .= $this->tag->tagHtml('label', ['for' => 'descSoftware']);
            $formSoftwares .= 'Descrição: ';
            $formSoftwares .= $this->tag->tagHtmlClose('label');
            $formSoftwares .= $form->render('descSoftware',['name' => 'soft[0][descSoftware]', 'require' => '']);
            $formSoftwares .= $form->render('fileSoftware');
            $this->view->formSoftwares = $formSoftwares;

jQuery,用于添加新行:

function addRow() {
    $(document).on('click', '#addSoftware', function(){

        var line = 0;
        $('.line').each(function(i,v){
            line = i + 1;
        });
        var html = $(this).parent().parent().html();

        html = html.replace('primary', 'warning');
        html = html.replace('plus', 'minus');
        html = html.replace('addSoftware', 'removeSoftware');
        html = html.replace(/soft\[0\]/g, 'soft['+line+']');

        $('#addWrapper').append('<div = class="block">'+html+'</div>');
        countRow();
        //maskPayment();
        removeRow();
    });
}

Jquery,Ckeditor 5:

    function getCkeditor() {
        let editorDescricao = null;

        ClassicEditor.create(document.querySelector(".descSoftware"), {
            language: 'pt-br',
          })
            .then(editor => {
              editorDescricao = editor;
            })
            .catch(console.error);
    }

我该如何进行?

感谢帮助!

0 个答案:

没有答案