Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

Custom message / error message for Save / Save and Publish


Reply


2 Posts   691 Views

Avatar
employboy

Community Member, 9 Posts

20 May 2011 at 8:44pm

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.

Avatar
cbq

Community Member, 2 Posts

13 December 2012 at 11:15pm

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.