我的注册验证有问题。我使用Symfony 2.6
,FOSUserBundle
,SonataUserBundle
。
这是我的AppBundle / Resources / config / validation.yml:
AppBundle\Entity\User:
properties:
workPhone: - NotBlank: { message: 'Укажите телефон организации', groups: AppRegistration}
adminPhone: -NotBlank: { message: 'Укажите телефон администратора', groups: AppRegistration}
name: -NotBlank: { message: 'Укажите название заведения', groups: AppRegistration}
adress: -NotBlank: { message: 'Укажите адрес заведения', groups: AppRegistration}
kitchen: -NotBlank : { message: 'Укажите тип кухни', groups: AppRegistration}
username: -NotBlank: { message: 'Укажите логин', groups: AppRegistration}
-MinLength: { limit: 4, message: "Логин не должен быть короче {{ limit }} символов", groups: AppRegistration }
-MaxLength: { limit: 12, message: "Максимальная длина логина {{ limit }} символов", groups: AppRegistration }
firstname: -NotBlank: { message: 'Укажите имя', groups: AppRegistration}
我的app / config / config.yml:
framework:
validation: { enabled: true, enable_annotations: true }
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
registration:
form:
type: app_bundle_user_registration
validation_groups: [AppRegistration, Registration]
但使用自定义规则的属性username
和firstname
不起作用!
验证,我在注释工作中添加了perfekt ... Yaml不