gpt4 book ai didi

forms - Symfony2表单重复错误也触发空白错误

转载 作者:行者123 更新时间:2023-12-01 09:34:12 24 4
gpt4 key购买 nike

我有一个“用户”表格:

public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('email', 'repeated', array(
'type' => 'email',
'first_name' => 'Email',
'second_name' => 'Confirm Email',
'invalid_message' => 'The email addresses you entered did not match.',
'error_bubbling' => true
))
->add('password', 'repeated', array(
'type' => 'password',
'first_name' => 'Password',
'second_name' => 'Confirm Password',
'invalid_message' => 'The passwords you entered did not match.',
'error_bubbling' => true
))
;
}

实体具有以下验证:
/**
* @var string $email
*
* @Assert\NotBlank(message="Please enter an email address")
* @Assert\Email()
* @ORM\Column(name="email", type="string", length=100, unique=true)
*/
private $email;

如果您在表单中输入不匹配的电子邮件地址,则即使用户显然输入了某些内容,也会触发@Assert \ NotBlank错误。当触发“重复”错误时,是否有办法阻止显示“空白”错误?

最佳答案

这是一个已知问题,这是Symfony Issues上的票:https://github.com/symfony/symfony/issues/2945

关于forms - Symfony2表单重复错误也触发空白错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7676920/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com