Hi,
I know this is an old one ...
I have started fighting with DataObjects and input validation in the CMS backend. Specifically, I have a DataObjectManager (DOM) which manages DataObjects. When the adminstrator adds a new DataObject via the DOM a popup form appears, they enter data, then hit save. Nothing special there. The sort of thing I need to do is reject the DataObject on save if there are any problems (i.e. empty fields).
This seems like obvious functionality and I can't be the first one to need a robust solution.
The best I have come up with so far is overriding DataObject::validate() and returning a ValidationResult object i.e. return ValidationResult(false, "you stuffed up");. That works, but I lose all the form fields, requiring the administrator to re-add them. They wont be happy with that (but they may have to be).
I have seen this problem mentioned once or twice but with no obvious solution. Does it require some modification to the 2.4.6 framework, or am I missing something?
I looked at overriding DataObject::getCMSValidtor() with my own RequiredFields validator (as I found in another post) but found that getCMSValidator() is not called by the framework - nor is it in the DataObject API.
How are the experts out there solving this problem?
Thanks very much,
J