I have one parent object that has several child objects that inherit its methods. When it comes time to validate forms, I have no idea how to NOT repeat the restrictions on validating parent fields.
Here is the code:
#validation.yml
Dir\Entity\Parent:
properties:
name:
- NotBlank: {message: 'name.empty'}
Dir\Entity\Child1:
properties:
name:
- NotBlank: {message: 'name.empty'}
age:
- NotBlank: {message: 'age.empty'}
Dir\Entity\Child2:
properties:
name:
- NotBlank: {message: 'name.empty'}
title:
- NotBlank: {message: 'title.empty'}
As you can see, the name property is returned again and again in the child constraint. Is there a way to include a parent constraint directly in a child constraint, so I don’t have to repeat parental constraint modifications?
Thanks in advance!
source
share