简体   繁体   English

当我尝试使用注释参数创建自定义消息时。 我收到[语法错误]

[英]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.

相关问题 我尝试查询时SQL语法错误 - Error in SQL syntax when I try a query 尝试使用Composer创建新的Laravel项目时,为什么会收到此错误消息? - Why I obtain this error message when I try to create a new Laravel projct using Composer? 当我尝试通过PHP创建数据库并设置用户权限时,MySQL语法错误 - Error in MySQL syntax when i try to create database and set user privileges through PHP 当我尝试在浏览器中运行此PHP文件时,收到错误消息 - When I try to run this PHP file in a browser, I get an error message 如何修复此错误[2045]或此[1054]当我尝试迁移表时,我总是在终端中收到此消息 - How to fix this error[2045] or this [1054] I always get this message in terminal when i try to migrate table GraphQL 在我尝试获取所有记录时返回错误消息“无法查询字段...” - GraphQL returns the error message "Cannot query field..." when I try to get all records 当管道到中间件时,我收到错误 "createError(N/error)"],"cause":{"name":"SSS_MISSING_REQD_ARGUMENT","message":"create: Missing a required arg - when piping to middleware I get error "createError(N/error)"],"cause":{"name":"SSS_MISSING_REQD_ARGUMENT","message":"create: Missing a required arg 当我尝试显示错误消息时,PHP 页面未加载 - PHP page does not load when I try to show an error message 我尝试上传文件时收到错误? - i get error when i try to upload a file? 当我尝试显示每个帖子的评论时出现错误 - I get an error when I try to show the comments for each post
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM