【问题标题】:The validation rule is not applicated to the field when using CKEditor with Symfony2 Form使用 CKEditor 和 Symfony2 表单时,验证规则不适用于该字段
【发布时间】:2015-02-25 13:43:51
【问题描述】:

如标题所示,当我将 CKEditor 类应用于我的 Symfony2 字段表单时,我不知道为什么:

->add('contentCours', null,array(
    'label' => 'Content: ', 
    'attr' => array('class'=>'ckeditor')))

如果表单提交,我会得到一个 SQL 异常,告诉我 colomun content_cours 不能为空!

但是当我从字段中删除 CKEditor 类 atrri 时,这不会发生......

我真的不知道这有什么问题,我在搞砸什么吗? 谢谢你的帮助:)

编辑:为了更清楚,我想要以下 => 如果“contenctCours”字段为空,请不要提交表单。

【问题讨论】:

    标签: forms validation symfony ckeditor field


    【解决方案1】:

    您应该检查您的 CKEditor 是否更新了 textarea 字段并纠正了表单提交时发送的 POST 请求。这也可能有助于"CKeditor update on submit post"

    【讨论】:

    • 感谢您的回答...老实说,Js 和 JQuery 不太好,我尝试了您建议的解决方案,但它对我不起作用,问题始终存在...
    • 无论如何,似乎是前端的问题,而不是后端的问题
    【解决方案2】:

    在我的情况下,CKEditor 没有发送 POST 数据,因为字段类型错误,我有 <input> 字段,但 CKEditor 需要使用 <textarea> 来保存 POST 数据,所以我必须从 @ 更改字段类型987654323@或TextTypeTextareaType

    别忘了导入类:

    使用 Symfony\Component\Form\Extension\Core\Type\TextareaType;

    例子:

    ->add('contentCours', TextareaType:class, array(
        'label' => 'Content: ', 
        'attr' => array('class'=>'ckeditor')
    ))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-24
      • 2012-04-25
      • 2018-09-11
      相关资源
      最近更新 更多