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

[SOLVED] Problem Adding DataObjectManager


Go to End


3 Posts   1090 Views

Avatar
zenmonkey

Community Member, 545 Posts

1 October 2009 at 9:54am

Edited: 01/10/2009 10:55am

I can't seem to add the DOM to CMS, its working in other page types, It must be a typo I'm not seeing

Here is the DataObject

class AccessCodeUser extend DataObject {
	static $db - array(
					   'Name' => 'Text',
					   'Email' => 'Text',
					   'ProductName' => 'Text'
					   );
	
	static $has_one = array(
		'AccessCodePage' => 'AccessCodePage',		   
	);
	
	public function getCMSFields_forPopup()
	{
		return new FieldSet (
							 new TextField('Name'),
							 new EmailField('Email'),
							 new TextField('ProductName')
							 );
	}
}

And in the PageType

class AccessCodePage extends Page {
	public static $db = array(
							  'LifestyleText' => 'HTMLVarchar(255)',
							  'AccessCode' => 'Text'
							  );
	
	public static $has_many = array (
							  'ExtraPageImages' => 'ExtraPageImages',
							  'AccessCodeUsers' => 'AccessCodeUser'
	);
	
	function getCMSFields() {
		$f = parent::getCMSFields();
		
		$f->removeFieldFromTab('Root.Content.Main', 'LifestyleText');
		$f->addFieldToTab("Root.Content.AccessCode", new TextField("AccessCode","Access Code"));
		$f->addFieldToTab("Root.Content.AccessCode", new DataObjectManager(
																		   $this,
																		   'AccessCodeUsers',
																		   'AccessCodeUser',
																		   array('Name' => 'Name','Email'=>'Email','ProductName' => 'ProductName'),
																		   'getCMSFields_forPopup'
																		   ));
		
		
		return $f;
		
	}
	
}

Avatar
UncleCheese

Forum Moderator, 4102 Posts

1 October 2009 at 10:09am

What do you mean you "can't?" Errors? What's it doing/not doing?

Avatar
zenmonkey

Community Member, 545 Posts

1 October 2009 at 10:47am

Edited: 01/10/2009 10:56am

Standard White Screen when Accessing the CMS even in Devmode. Everything is fine until I add the DataObejctManager.

EDIT Found the Typo