实体属性:
/**
* @var string $content
*
* @ORM\Column(name="content", type="string", length=300)
* @Assert\NotBlank(message="Please enter question")
* @Assert\Length(
* min = "15",
* max = "300",
* minMessage = "Text question must be larger than 15 symbol",
* maxMessage = "Text question must be less than 300 symbol"
* )
*/
protected $content;
表单提交(在控制器中):
// Add questions
if ($request->getMethod() === 'POST') {
$formQuestion->bind($request);
if ($formQuestion->isValid()) {
// Here code save question
}
else {
$errors = $formQuestion->getErrors():
// Null array ((
}
}
没有错误显示(( 为什么不读取注释验证。其他属性是很好的验证。
答案 0 :(得分:1)
is you set form reset tag in your twig template
like this
{{ form_rest(form) }}