doutao4938 2013-09-27 09:23
浏览 19
已采纳

如何在CakePHP中设置Tinymce的值

I am using CakePHP 2.4.1 and Tinymce for CakePHP2. I have an Edit page and I want to give some default text (extracted from the database) to one of the <textarea>'s. Using plain Cake code I have this:

echo $this->Form->input('conditii_plata',array(
    'value'=>$conditii_plata[0]['Setare']['value'], 
    'escape'=>false,
    'type' => 'textarea',
));

My question: If I convert it to Tinymce I can't give it a default value. Is this possible to do?

  • 写回答

1条回答 默认 最新

  • dsaxw4201 2013-09-27 10:44
    关注

    No, you cannot without setting the text from Javascript upon TinyMCE init.

    You could make your textarea hidden and have a second textarea deal with TinyMCE In your document ready javascript function:

    tinymce.init({
        selector: '<id of your second textarea>',
        ....
        setup : function(editor){
            editor.on('init', function(e){
                //copy from hidden textarea
                editor.setContent($('<1st textarea id').val());
            });
        });
    });
    

    Then your should manually submit your form and before sending copy the tinymce content to your hidden textarea.

    Another aproach is to encode your data to json and deal with it from javascript.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile
  • ¥15 写uniapp时遇到的问题
  • ¥15 vs 2008 安装遇到问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码