Jump to:

5540 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Custom message / error message for Save / Save and Publish

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

Page: 1
Go to End
Author Topic: 671 Views
  • employboy
    Avatar
    Community Member
    9 Posts

    Custom message / error message for Save / Save and Publish Link to this post

    After much trawling of the forums I'm still getting nowhere with this yet it seems such a basic request.

    On my dataobject I'm using:

    function onBeforeWrite(){
        if(Director::is_ajax()) {
        $dbrecord = DataObject::get_by_id("ItemInQuestion",$this->record['ID']);
           if(strlen(strip_tags($this->Content)) > 100){
                $this->record['Content'] = $dbrecord->Content;
           }
    }
       parent::onBeforeWrite();
    }

    Hopefully you can see what I'm trying to do here. I'm preventing CMS users from entering any content over 100 characters in length. Whilst this works I've no way of giving the user feed back in the case that they've entered too much text. I'd like the green or red box in the bottom left which give the response of the ajax request to read something like - 'Please keep text less that 100 characters'.

    Thanks chaps.

  • cbq
    Avatar
    Community Member
    2 Posts

    Re: Custom message / error message for Save / Save and Publish Link to this post

    do you still need the solution? took me days to figure it out but there is clean way to do this if you find out how.

    671 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.