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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Cant seem to implement SimpleImageField and ImageField in SS 2.4.5


Go to End


2 Posts   1388 Views

Avatar
kharmer

Community Member, 8 Posts

22 March 2013 at 5:51am

Hi All,

I am trying to implement an image field for a cusatom page type. This is what I have in my class that extends Page.

	static $db = array(
		'Subtitle' 				=> 'Text',
		'TitleImage' 			=> 'ImageField',
	);
	static $has_one = array(
	);

	/* admin icon */
	static $icon = 'themes/bayer/images/treeicons/folder-blue';
	
	/* allowed child page types */
	static $allowed_children = array('');

	function getCMSFields() {
		$fields = parent::getCMSFields();

		/**/
		// Remove fields
		/**/
		//$fields->removeFieldFromTab("Root.Content.Main","Content");
		$fields->removeFieldFromTab("Root.Content.Main","Excerpt");
		$fields->removeFieldFromTab("Root.Content.Main","isNew");
		$fields->removeFieldFromTab("Root.Content.Main","ArticleDate");
		$fields->removeFieldFromTab("Root.Content.Main","lastEditDate");
		$fields->removeFieldFromTab("Root.Content.Main","isNewTimeoutDate");
		$fields->removeFieldFromTab("Root.Content.Main","featurePage");
		$fields->removeFieldFromTab("Root.Content.Main","featurePageProblemSec");
		$fields->removeFieldFromTab("Root.Content.Main","bgMark");
		$fields->removeFieldFromTab("Root.Content.Main","moreLink");
		// $fields->removeFieldFromTab("Root.Content.Main","MenuTitle");
		
		/**/
		// Add
		$fields->addFieldToTab('Root.Content.Main', new TextField('Subtitle', 'Page subtitle (right under main title)'), 'MenuTitle');
		$fields->addFieldToTab('Root.Content.Main', new ImageField('TitleImage', 'Page title image (top right corner)', null, null, null, "Fungicide"), 'MenuTitle');
	}

When I go to the admin side and try to edit a page using this page type, I get errors!! I get the popup error with an SQL statement issue.

Any ideas!?

I'm stuck on SS 2.4.5 as I have in herited this project and upgrading it out of scope! :(

Any help very much appreciated,
K...

Avatar
Willr

Forum Moderator, 5523 Posts

26 March 2013 at 8:07pm

While in the CMS you need to use the FileIFrameField