0
實體屬性:不工作註釋validatation在Symfony的2.1
/**
* @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 ((
}
}
沒有錯誤顯示(( 爲什麼不看註釋驗證其它性能還是不錯的。驗證
您是否嘗試將POST檢查之外的bind()? – alex88