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

Edit a field in image-table from within another page or dataobject


Go to End


1238 Views

Avatar
theAlien

Community Member, 131 Posts

13 January 2010 at 3:20am

Edited: 13/01/2010 3:21am

Hi,
I have the following structure:

class SomePage extends Page {
	static $has_one => array(
		'SomeImages'	=> 'SomeImage'
	);
	static $has_many => array(
		'SomeDataObjects'	=> 'SomeDataObject'
	);
}
...
class SomeDataObject extends DataObject {
	static $has_one => array(
		'SomePages'	=> 'SomePage',
		'SomeImages'	=> 'SomeImage'
	);
}
class SomeImage extends DataObjectDecorator {
	function extraStatics() {
		return array(
			'db' => array(
				'Copyright'	=> 'Varchar(50)'
			)
		);
	}
}

Since copyrights directly belong to one specific image, and since they should be set ideally together with uploading an image (either related to SomePage or SomeDataObject, that shouldn't matter), I would like to create a TextField in SomePage and SomeDataObject that writes and gets it's values directly to and from the Copyright db-field in SomeImage.

My question: is this possible and how...?