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

HELP! HTMLText field not displaying in CMS :(


Go to End


2 Posts   6979 Views

Avatar
Radweb

18 Posts

3 April 2009 at 4:50am

Edited: 03/04/2009 11:14pm

Hi all,

Having trouble trying to a get WYSIWYG field working on my job postings board... When I use a Textareafield its loads okay but I have to manually type HTML fields. .. I'm looking to get a basic HTML editor in there with just the common text formatting. Followed instructions to this point:

class JobBoard extends DataObject {
static $db = array(
'JobTitle' => 'Varchar',
'JobDescription' => 'HTMLText', // Declared HTMLText when building the custom database table

$fields = new FieldSet(

new ReadonlyField('ID','id #',$id),
new TextField('JobTitle', 'Job Title', 'New Job'),
new HtmlEditorField("JobDescription", "Job Description"), // Declared HTMLEditor field (but shows nothing in CMS)

$form->loadDataFrom(array(
'ID' => $currentJob->ID,
'JobTitle' => $currentJob->JobTitle,
'JobDescription' => $currentJob->JobDescription, // Load data into it - which works fine on Textareafield

Fresh pair of eyes would be very much appreciated;

I'm using silverstripe 2.2.2.

Cheers

Steve

Avatar
Artyom

Community Member, 22 Posts

24 April 2009 at 9:14am

Edited: 24/04/2009 9:15am

I just did the following and it worked.

class HomePage extends Page {

public static $has_one = array(
'HomePageText1' => 'HTMLText',
// ...
);

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

$fields->addFieldToTab("Root.Content.HomePageTextAreas", new HtmlEditorField('HomePageText1', 'HomePageText1'));

return $fields;
}
}

I think it might have something to do with the fact that you are assigning

$fields = new FieldSet(...);

Rather then adding to the array.