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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

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

Custom message / error message for Save / Save and Publish

Go to End

2 Posts   1176 Views


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;

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.


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.