CKEditor + Yii loaded with AJAX : $_POST doesn't contain the updated value

妖精的绣舞 提交于 2019-12-05 20:58:33
thaddeusmt

Sounds like a typical post-AJAX JS binding issue. :) There are a few possibilities for how to fix it, depending on what is going wrong.

This post in the Yii forum should be money for you, it's where I got most of these suggestions: http://www.yiiframework.com/forum/index.php?/topic/9341-ckeditor-widget-in-a-cactiveform/

  1. Use a widgetized Yii extension which has already solved this problem (NHCKEditor?)
  2. Add an onClick callback to the submit button which saves the CKEditor content to the hidden 'textarea' ('onclick'=>'CKEDITOR.instances.TEXTAREA_ID.updateElement()',
  3. Use jQuery to get the data from the CKEditor iFrame to use... wherever. AJAX validation, etc.

Good luck!

You can let CKEDITOR update the textarea before validating, and clientside/ajax validation will work as expected:

<?php $form = $this->beginWidget('CActiveForm', array(
    'enableAjaxValidation' => true,   // one or both
    'enableClientValidation' => true, // one or both
    'clientOptions' => array(
        'validateOnSubmit' => true,   // optional
        'beforeValidate' => new CJavaScriptExpression('function(form) {
            for(var instanceName in CKEDITOR.instances) { 
                CKEDITOR.instances[instanceName].updateElement();
            }
            return true;
        }'),
    ),
)); ?>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!