Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » CMS DataObject validation

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 484 Views
  • jizzman
    Avatar
    Community Member
    23 Posts

    CMS DataObject validation Link to this post

    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

    484 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.