The createFormBuilder
pass through a class Called 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. 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 ***
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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.