yaml - symfony2 validation inheritance -
i have 1 parent entity has multiple kid entities inherit methods. when comes time validate forms have no thought how not repeat each parent fields validation constraints.
here 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 can see, name property coming 1 time again , 1 time again in kid constraint. there way include parent constraint straight in childs 1 won't have repeat parent constraints modifications?
thanks in advance!
sorry yokoloko forget give solutions. here's i've done:
i've created constraint validation parent won't have reproduce code everytime create child. hence focus on child's fields when necessary.
here's inspired me http://symfony.com/doc/master/cookbook/validation/custom_constraint.html
let me know if need additional details
symfony2 yaml
No comments:
Post a Comment