Forms 将CKEditor与Symfony2表单一起使用时,验证规则不应用于字段

Forms 将CKEditor与Symfony2表单一起使用时,验证规则不应用于字段,forms,validation,symfony,ckeditor,field,Forms,Validation,Symfony,Ckeditor,Field,正如标题中所述,我不知道为什么我将CKEditor类应用于我的Symfony2字段表单,如下所示: ->add('contentCours', null,array( 'label' => 'Content: ', 'attr' => array('class'=>'ckeditor'))) 如果提交了表单,我会收到一个SQL异常,告诉我colomuncontent\u cours不能为空 但当我从字段中删除CKEditor类atrri时,这不会发生

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

->add('contentCours', null,array(
    'label' => 'Content: ', 
    'attr' => array('class'=>'ckeditor')))
如果提交了表单,我会收到一个SQL异常,告诉我colomun
content\u cours
不能为空

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

我不知道这到底是怎么回事真的,我搞砸了吗? 谢谢你的帮助:)


编辑:更清楚地说,我希望下面的=>如果“contenctCours”字段为空,不要再提交表单。

您应该检查您的CKEditor是否更新了textarea字段以及表单提交时发送的正确POST请求。这也可能有助于

在我的情况下,由于字段类型错误,CKEditor没有发送POST数据,我有
字段,但CKEditor需要使用
保存POST数据,因此我必须将字段类型从
null
TextType
更改为
TextareaType

别忘了导入类:

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

例如:

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

谢谢你的回答…我对Js和JQuery不太在行,我尝试了你建议的解决方案,但它对我不起作用,问题总是存在…不管怎样,似乎它的前端问题,而不是后端问题