エンティティ プロパティ:
/**
* @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 ((
}
}
エラーは表示されません (( 注釈の検証を読み取らない理由。他のプロパティは適切な検証です。