Jump to:

23483 Posts in 18976 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Aborting a save in onbeforewrite:

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 223 Views
  • BigD1214
    Community Member
    15 Posts

    Aborting a save in onbeforewrite: Link to this post

    Is there a way to abort a save if a condition in the onbeforewrite: function is not met? Please help!
    Thanks so much!

  • swaiba
    Forum Moderator
    1792 Posts

    Re: Aborting a save in onbeforewrite: Link to this post

    Hi BigD1214,

    As there is no return type the only suggestion I would have is to use "die()" there - but that is truly awful and you must be able to fix another way... probably using a validator...

    This addresses their use within ModelAdmin...


    And it is [kinda] the same for a form. Only directly in the code if you create / write will there be an issue -but hey you can call validation right there (either custom or reuse any validator you create)

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.