Я установил CKEditor 5 более чем на один, все редакторы отображаются нормально, но только первый, который я могу сохранить на БД.
Я меняю название каждой текстовой области. Первая строка [0] [descSoftware], следующая строка [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);
}
Как мне продолжить?
Спасибо за помощь!