我正在使用symfony,我想在用户名不符合模式时显示错误,我该怎么做?
{{ form_widget(form.username, {'attr':{'pattern': '[a-zA-Z]*'} }) }}
答案 0 :(得分:0)
尝试将Assert添加到实体类中的属性中。
请查看Asserts:http://symfony.com/doc/current/validation.html
这个正则表达式:http://symfony.com/doc/current/reference/constraints/Regex.html