How to get TinyMCE form validation working

Notice: This thread is very old.
jarjar
Member | 4
+
0
-

Hi,
I tried to get TinyMCE form validation working following https://pla.nette.org/…installation. Editor works fine but validation does not. I have no idea what's wrong/missing. Could someone please help?

layout.latte:
<!-- TinyMCE-->
<script src=“//cdn.tinymce.com/4/tinymce.min.js”></script>
<script>tinyMCE.init({
mode: “specific_textareas”,
editor_selector: “mceEditor”,
});</script>

PostPresenter.php:
protected function createComponentPostForm()
{
$form = new Form;
$form->addText(‘title’, ‘Title:’)
->setRequired();
$form->addTextArea(‘content’, ‘Content:’)
->setAttribute(‘class’, ‘mceEditor’)
->setRequired();

$form->addSubmit(‘send’, ‘Save and publish’);
$form->getElementPrototype()->onsubmit(‘tinyMCE.triggerSave()’);
$form->onSuccess[] = array($this, ‘postFormSucceeded’);

return $form;
}

GEpic
Member | 566
+
0
-

Try this:

<script>
    tinymce.init({
		/* Your configuration */
        setup: function (editor) {
            editor.on('change', function () {
                tinymce.triggerSave();
            });
        }
    });
</script>

Last edited by GEpic (2017-02-21 01:22)

Gappa
Nette Blogger | 208
+
0
-

I'm using almost the same, just slightly tweaked – with blur event instead of change.

<script>
	tinymce.init({
		/* Your configuration */
		setup: function(editor) {
			editor.on('blur', function() {
				editor.save();
			});
		}
	});
</script>

Last edited by Gappa (2017-02-21 06:59)