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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

DataObjectManager Module: Make All Text Lowercase

Go to End

3 Posts   1479 Views


Community Member, 197 Posts

17 August 2010 at 5:38am

When items are added with the DataObjectManager Module, I want them to be saved such that all uppercase letters are converted to lowercase letters.

Here is my code:


class SectionItem extends DataObject
	static $db = array (
		'Section' => 'Text'

	public function getCMSFields_forPopup()
		return new FieldSet(
			new TextField('Section')


Community Member, 254 Posts

18 August 2010 at 3:25pm

function onBeforeWrite() {
$this->Section = strtoupper($this->Section);


Forum Moderator, 4102 Posts

18 August 2010 at 4:03pm

Are you sure about that, Bambii? $this->Section refers to the current value. Since the record hasn't been written at this point, the object is still storing the old value. You need to get the value that was passed through the form. Something like $_REQUEST['Section'], for instance, but there has to be a cleaner way.