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.

Customising the CMS /

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

DataObject Fields in Tab


Go to End


1835 Views

Avatar
joern

Community Member, 28 Posts

18 February 2010 at 3:28am

Edited: 18/02/2010 3:47am

Hi,
I am working on an extension of GoogleMapSelectableField, which manages this in a DataObject.
Currently it is so that it establishes a $has_one-relationship and thus receives a new tab. This also works great, but will not save the data.
Here are parts of the codes:

Page with Location:

class geoPage extends Page
{ …
	static $has_one = array(
		'Location' => 'Location'
	);
	…
	public function getCMSFields() 
	{ …
		$location = $this->Location();
		$fields->addFieldsToTab("Root.Content.Location", $location->getCMSFields() );
	}
}

Location DataObject:

class Location extends DataObject 
{
	function getCMSFields()
	{
		$fields = parent::getCMSFields();
		$fields = $this->scaffoldFormFields(array(
			'fieldClasses' => array(
				'Lat'							=> 'HiddenField'
				,'Lng'						=> 'HiddenField'
				,'Zoom'						=> 'HiddenField'
				,'FormatedAddress'				=> 'GoogleMapSelectableField'
				…
			)
		));
		return $fields;
	}

When I mount it so I also receive among my fields, a dropdown box with all geoPages.
But I get no connection between the Page and the Location.

I hope you can help me
Jörn

I forgot: I use silverstripe 2.4 beta

Edit: add Image & beta info

Attached Files