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

HTML Field


Go to End


5 Posts   3578 Views

Avatar
sheadawson

Community Member, 49 Posts

14 March 2011 at 4:53pm

Hey all,

I need an HTML editor field for my DataObject's Content field, which is managed in a data object manager popup window.

Problem:

SimpleHTMLEditorField: does not appear

SimpleTinyMCEField: renders a plain textarea

SimpleWYSIWYGField: also renders a plain textarea

I'm using SS 2.4.5 and the latest DOM.

This is my code:

HTMLWidget.php

class HTMLWidget extends DataObject
{
	static $db = array(
		"Title" => "Varchar",
		"Content" => "HTMLText",
		"Color" => "Varchar"
	);	
	
	static $has_one = array(
		"Page" => "Page"
	);
	
	function getCMSFields()
	{	
		$fields = parent::getCMSFields();
		$fields->addFieldToTab("Root.Main", new TextField('Title', 'Widget Title'));
		$fields->addFieldToTab("Root.Main", new TextField('Color', 'Title Background Color'));
		$fields->addFieldToTab("Root.Main", new SimpleWYSIWYGField('Content', 'Content'));
		return $fields;
	}
}

Page.php

class Page extends SiteTree
{

	public static $db = array(
	);
	
	static $has_many = array(
    	"HTMLWidget" => "HTMLWidget",
    );
     
    function getCMSFields() 
    {
   		$fields = parent::getCMSFields();
   		$widgets = new DataObjectManager(
			$this,
			'HTMLWidget',
			'HTMLWidget'
		);
 	 	$fields->addFieldToTab("Root.Content.Widgets", $widgets);
    	return $fields;
    }

}

What do I gotta do!?

Thanks in advance :)

Avatar
UncleCheese

Forum Moderator, 4102 Posts

14 March 2011 at 5:52pm

I think if you're on the latest version from GitHub, that bug is fixed.

git://github.com/unclecheese/DataObjectManager.git

Avatar
sheadawson

Community Member, 49 Posts

14 March 2011 at 6:44pm

Outstanding! Thank you :)

Avatar
spierala

Community Member, 80 Posts

27 October 2011 at 2:45am

Edited: 27/10/2011 2:46am

hello all,
I have exactly the same problem:

SimpleHTMLEditorField does not show up in cms popup.
Also with newest dataobject manager version...

That´s my code:

class StartPage extends Page {

	....
	
	function getCMSFields() {
		$fields = parent::getCMSFields();
		
		$newsTablefield = new DataObjectManager(
			$this,
			'NewsItem',
			'NewsItem',
			array(
			'Date' => 'Datum',
			'Title' => 'Titel',
			'Text' => 'Text'
			),
			'getCMSFields_forPopup'
		);
		
		$fields->addFieldToTab("Root.Content.Neuigkeiten", $newsTablefield);
		return $fields;
	}
}

class NewsItem extends DataObject {

	....

	function getCMSFields_forPopup() {
		$fields = new FieldSet();
		
		$dateField = new DateField('Date','Datum');
		$dateField->setConfig('showcalendar', true);
	        $dateField->setConfig('dateformat', 'dd.MM.YYYY');
		$fields->push( $dateField );
		$fields->push( new TextField('Title', 'Titel') );
		$fields->push( new SimpleHTMLEditorField('Text', 'Text') );
		
		return $fields;
	}
}

many thanks in advance,
Florian

Avatar
neilcreagh

Community Member, 136 Posts

12 November 2011 at 3:30am

Hi Florian,

I just had this same problem, then found that I should have been using 'SimpleTinyMCEField' instead of 'SimpleHTMLEditorField' and that worked for me.