1

首先是一个例子,我们可以这样做

framework:
    form:            true
    csrf_protection: false

(看看csrf_protection

或者在 formType 中设置它(但如果我们不想在我们拥有的所有表单中这样做,那么在配置中更好)

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
    $resolver->setDefaults(array(
        'data_class' => 'Eve\CommonBundle\Form\Entity\formLogin',
        'required' => false,
        //'csrf_protection' => false
    ));
}

我的选择是在 config.yml 中声明它。现在,这是一个例子,问题是......

在 FormType 我们有诸如

        'required' => false // disabling html5 check to test POST types

我如何在 config.yml 中设置它?

ps:如果我将它设置为与'csrf_protection'相同的方式它不起作用

4

1 回答 1

0

似乎没有从配置文件中禁用 html5 验证的选项,请查看参考手册(没有引用它):http ://symfony.com/doc/current/reference/configuration/framework.html

由于它更多地取决于视图,因此您应该将有效的 html 属性“novalidate”添加到所有表单模板中,并且不要在表单类中管理它(即使可能^^):

<form novalidate="novalidate"></form>

导航器不会验证必填字段(与所有导航器兼容!)。轻松解决你的问题!

于 2013-03-29T17:18:24.890 回答