今、私は、1つのファイル内のすべてのバンドルのエンティティを検証するvalidation.ymlというファイルを持っています。Symfony2では、validation.ymlファイルをインポートを使用して複数のファイルに分割できますか?
validation.yml
Blogger\BlogBundle\Entity\Comment
properties:
username:
- NotBlank:
message: You must enter your name
- MaxLength: 50
comment:
- NotBlank:
message: You must enter a comment
- MinLength: 50
Blogger\BlogBundle\Entity\Enquiry:
properties:
name:
- NotBlank: ~
email:
- Email:
message: symblog does not like invalid emails. Give me a real one!
subject:
- NotBlank: ~
- MaxLength: 50
body:
- MinLength: 50
しかし、私は2つのファイルに分割し、それらの両方をインポートしたいと思います。
validation.yml
imports:
- { resource: comment.yml }
- { resource: enquiry.yml }
comment.yml
Blogger\BlogBundle\Entity\Comment
properties:
username:
- NotBlank:
message: You must enter your name
- MaxLength: 50
comment:
- NotBlank:
message: You must enter a comment
- MinLength: 50
enquiry.yml
Blogger\BlogBundle\Entity\Enquiry:
properties:
name:
- NotBlank: ~
email:
- Email:
message: symblog does not like invalid emails. Give me a real one!
subject:
- NotBlank: ~
- MaxLength: 50
body:
- MinLength: 50
あなたはどういう "動作しませんでした" ?例外がスローされたか、何も起こりませんでしたか? – Problematic
フォームは正しく検証されずに提出されました。 – intrepion