Please don't recommend 'cancelOnFail' because it doesn't work properly if I'm validating more than one field
$this->add(
'email',
new PresenceOf(
[
'message' => 'The e-mail is required',
]
)
);
$this->add(
'email',
new Email(
[
'message' => 'The e-mail is not valid',
]
)
);
如果仅显示第一条错误消息,则应这样编写。
$messages->current()->getMessage()
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.