0

i have an entity with an end date property. If the user edits the entity and changes the date, it shouldn't be allowed that the new date is before the date it was before. Is it possible to get the bounded entity in my validator to check the dates or how can i solve that?

Thanks in advance!

kuldeep.kamboj
  • 2,566
  • 3
  • 26
  • 63
Dominik Barann
  • 675
  • 2
  • 10
  • 25
  • Use Custom Validator http://framework.zend.com/manual/current/en/modules/zend.validator.writing-validators.html – kuldeep.kamboj Mar 24 '15 at 13:51
  • I know that i have to use a custom validator, but how can i get the bounded entity in that validator? – Dominik Barann Mar 24 '15 at 13:58
  • Hmm I don't think you could use bounded entity. But inside custom validator, you can fetch your id column value from form-data, and then can use doctrine query/modal through get information to validate against existing end date. – kuldeep.kamboj Mar 24 '15 at 14:05

1 Answers1

0

If you are using doctrine 2 you can use/extend the ObjectExists validator (Using a query to find the entity you are interested in) and then add some custom validation to the entity like checking the date field.

Refer to the Doctrine 2 documentation for details on the ObjectExists validator.

Wilt
  • 41,477
  • 12
  • 152
  • 203