[英]When I try to create a custom message with annotation argument. I get [Syntax Error]
The createFormBuilder
pass through a class Called RegisterValidation()
createFormBuilder
通过名为RegisterValidation()
的类传递
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Validator\Constraints as Assert;
class RegisterValidation extends AbstractType
{
/**
* @var string
* @Assert\NotBlank( message = 'Enter first name please.') //This parameter trows an error
*/
public $firstName;
}
I'm learning annotations it looks very nice to use every day on a project. 我正在学习注释,每天在项目上使用它看起来非常不错。 Unfortunately, this issue seems so specific that I cannot find any Symfony 4 documentation.
不幸的是,这个问题似乎太具体了,以至于我找不到任何Symfony 4文档。 I want to use a custom message to replace the default one.
我想使用自定义消息替换默认消息。
The full error message is probably : 完整的错误消息可能是:
[Syntax Error] Expected PlainValue, got ''' at position ***
[语法错误]预期的PlainValue,在位置***处有“''
As explained, your message in annotation should be between doubles quotes "
. 如前所述,您在标记消息应该是双引号,之间
"
。
class RegisterValidation extends AbstractType
{
/**
* @var string
* @Assert\NotBlank(message="Enter first name please.") // Message must be in double quotes
*/
public $firstName;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.