0

实体属性:

 /**
 * @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 ((
  }
}

没有错误显示((为什么不读取注释验证。其他属性很好验证。

4

1 回答 1

1
 is you set form reset tag in your twig template 

like this 
 {{ form_rest(form) }}
于 2013-04-03T18:22:46.907 回答