【问题标题】:Symfony 2.1 - Client side validation is only working for required contraintSymfony 2.1 - 客户端验证仅适用于所需的约束
【发布时间】:2013-04-03 17:45:50
【问题描述】:

由于Entities 的断言从MinLengthMaxLength 更改为LengthMinMax 更改为Range,验证器猜测者没有遵循这些更改,max_length属性未填充,因此 HTML 验证不适用于 length

我认为guessMaxLengthForConstraint函数中的Symfony\Component\Validator\Constraints\Length应该有一个新案例Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser.php

还是解决了。

我使用的是 2.1.6 但我尝试了 2.1.7 并没有什么区别 我正在使用这个:

/**
* @var float $height
*
* @ORM\Column(name="height", type="decimal", nullable=true)
* 
* 
* @Assert\Range(
*      min = "20",
*      max = "96",
*      minMessage = "You must be at least 20 tall",
*      maxMessage = "You cannot taller than 96"

* )      
* @Assert\NotBlank(groups={"registration_step_two","profile_measurement"})  
* @Assert\Regex(pattern= "/[0-9]/",message="Require number only") 
* @Assert\MinLength(10)
*/ 

【问题讨论】:

标签: validation symfony orm symfony-2.1


【解决方案1】:

我向他们添加了组验证,它终于工作了

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-08
    • 2012-11-13
    • 2012-08-17
    • 1970-01-01
    相关资源
    最近更新 更多