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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

canDelete and functions in the constructors FieldList


Go to End


962 Views

Avatar
Chris_Bryer

Community Member, 35 Posts

9 June 2011 at 5:43pm

For some reason i cant get a dataobject's function canDelete() and canEdit() to work on DataObjectManager. my code works with CTF, but not DOM.


class MyDataObject extends DataObject{
...
     function canDelete(){
		switch($this->Title){
			case 'None':
				return false;
				break;
			default:
				return true;
				break;
		}
		return true;
	}
}

also, with ComplexTableFields, i can call a function through the fieldList in the CTF constructor. I can also get values from relationships through dot notation as well. how can i do this with DOM? here's an example with CTF's:

(in DataObject 'OptionItem')
function weightWithSymbol(){
		return $this->WeightModifier.' lbs';
	}

(in CTF constructor)
$optionSet = new ComplexTableField(
			$this,
			'ProductOptions',
			'OptionItem',
			array(
				'Title' => 'Title',
				'weightWithSymbol' => 'Weight Modifier',
				'PriceModifier' => 'Price Modifier',
				'CodeModifier' => 'Code Modifier',
				'ProductOptionGroup.Title' => 'Option Group'
			),
			'getCMSFields',
			'',
			'ProductOptionGroupID'
		);

thanks,
-Chris