TinyMCE must prevent form submission

I have a problem with TinyMCE. In my CakePHP v3 based application, I have a form for adding loyalty tasks. There is a field that uses tinymce to describe the task.

So the problem is when I fill out the form with data and click the submit button, nothing happens. Moreover, there is a form for editing tasks, and it works fine (exactly the same). Custom JS is not added for the problematic form.

I know that TinyMCE with a demand on textarea causes a problem, because when I turn it off, it works fine.

Some codes:
Initialization of TinyMCE:

tinymce.init({
    selector: 'textarea.tinymce',
    height: 500,
    plugins: [
        "advlist autolink link image lists charmap preview hr anchor image",
        "wordcount visualblocks visualchars fullscreen insertdatetime nonbreaking",
        "table paste"
    ],
    toolbar1: "undo redo cut copy paste | bold italic underline strikethrough subscript superscript | alignleft aligncenter alignright alignjustify | table",
    toolbar2: "formatselect | outdent indent | bullist numlist | blockquote link unlink charmap hr image | preview",
    menubar: false,
    content_css: [
        '//www.tinymce.com/css/codepen.min.css'
    ]
});

Form (removed several elements):

<?= $this->Form->create(null, ['enctype'=>'multipart/form-data']); ?>
<div class="col-xs-12">
    <div class="form-group">
        <label>Tytuł</label>
        <input type="text" name="title" class="form-control" required="required"/>
    </div>
</div>
//additional elements
<div class="col-xs-12">
    <div class="form-group">
        <label>Treść zadania</label>
        <textarea name="task" class="form-control tinymce" required="required"></textarea>
    </div>
    <input type="submit" class="" value="Dodaj"/>
</div>
<?= $this->Form->end(); ?>

TinyMCE Version Used: 4.6.4 (newest version)

+4
2

, tinymce.

, : tinyMCE.

setup: function (editor) {
    editor.on('change', function (e) {
        editor.save();
    });
}
+2

, , , required . : , . , required="required" tinymce - js , cakephp .

0

Source: https://habr.com/ru/post/1681259/


All Articles