donglao7947 2016-10-30 16:20
浏览 67
已采纳

用ckeditor不能$ _POST

I'm having trouble with CKEDITOR and i was hoping you could help me out.

I have this code inside a form tag:

        <div class="column column-1">
            <h3>Content</h3>
            <textarea id="editor1" name="editor1" type="text"></textarea>
        </div>

I applied the next javascript to make the ckeditor work:

CKEDITOR.replace("editor1"); 

So far so good the editor is showing in my browser i can type in it and all that good stuff.

Now i tried to work with it using PHP:

echo $_POST['editor1'];

If the user submits the form it should echo editor1 The problem is its not happening. I tried to run multiple tests but its just not showing me anything. If i do the same with a normal textarea (not a ckeditor one) just the standard textarea it works. WHen i do it with ckeditor it wont work.

  • 写回答

1条回答 默认 最新

  • dpicx06888 2016-10-30 16:35
    关注

    I've run into this issue myself, I'm not sure my solution is 'best practice' but it does seem to work without issues.

    What I've done is added an option-setting when initiating the editor to caputre the input content 'on change' and add it to your original textarea (which ckeditor will 'hide' before initiating itself).

    The code:

    CKEDITOR.replace( 'editor1', {
            on : { 
                change: function ( evt )  {
                  $('textarea[name="editor1"]').html(evt.editor.getData());
                }
            }
    }); 
    

    Notice the 'change' event-listener that updates the hidden text area.

    Alternativly, you should be able to use the getData() function to retrieve the editor contents when the form is submitted (e.g. if you are using ajax etc.).

    Hope this helps.

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

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c