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.

Data Model Questions /

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

has_many Files and AssetTableField


Go to End


3 Posts   2339 Views

Avatar
netnoise

Community Member, 10 Posts

2 March 2010 at 12:09am

Hi!

I am trying to use the AssetTableField for linking multiple files to a page, but the selection in AssetTableField does not get saved. Did I miss some point? Any hint is highly appreciated.

Thanks!

<?php

class ContentPage extends Page {
	
	// database relations
	public static $db = array(
	);
	
	public static $has_one = array(
	);
	
	public static $has_many = array(
		'Files' => 'File'
	);	

	// fields in CMS
	function getCMSFields() {
		$fields = parent::getCMSFields();
		$downloadsTable = new AssetTableField(
			$this,
			'Files',
			'File',
			array(
				'Title' => 'Bezeichnung',
				'Filename' => 'Dateiname'
			)
		);
			
		$fields->addFieldToTab('Root.Content.Downloads', $downloadsTable);
		
		return $fields;
	}   
	
}
?>

Avatar
johannes

Community Member, 20 Posts

11 April 2010 at 5:04am

Same problem here, can't anybody help with this?

Avatar
timcole

Community Member, 32 Posts

23 April 2010 at 2:16am

I my experience the DataObjectManager module (which includes FileObjectManager) is generally an easier and nicer way to do these sorts of things. Take a look on the modules page for it - there are some good tutorials and a specific area on the forum.