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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Error Saving Content with Html Editor Field


Reply


5 Posts   3195 Views

Avatar
Patrick Arlt

Community Member, 15 Posts

20 September 2009 at 8:23am

Edited: 20/09/2009 8:32am

I don't know if these 2 problems are related but i have having a problem with content not saving when i click save or save and publish on one of my page types called InsidePage. All my other templates work just great.

Here is my code for the InsidePage Template.

<?php
/**
* Defines the InsidePage page type
*/

class InsidePage extends Page {
static $db = array(
   'Email' => 'Text',
   'Phone' => 'Text',
   'Location' => 'Text',
   'Webstie' => 'Text',
   'Twitter' => 'Text',
   'Facebook' => 'Text',
   'Flickr' => 'Text',
   'StudentDevelopment' => 'HTMLText',
   'Sustainability' => 'HTMlText',
   'Diversity' => 'HTMLText'
);

static $has_one = array (
   );

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

   $fields->addFieldToTab('Root.Content.Contact', new TextField('Phone'));
   $fields->addFieldToTab('Root.Content.Contact', new TextField('Email'));
   $fields->addFieldToTab('Root.Content.Contact', new TextField('Location'));
   
   $fields->addFieldToTab('Root.Content.Links', new TextField('Website'));
   $fields->addFieldToTab('Root.Content.Links', new TextField('Twitter'));
   $fields->addFieldToTab('Root.Content.Links', new TextField('Facebook'));
   $fields->addFieldToTab('Root.Content.Links', new TextField('Flickr'));

   $fields->addFieldToTab('Root.Content.StudentDevelopment', new HtmlEditorField("StudentDevelopment","GreyboxContent"));
   $fields->addFieldToTab('Root.Content.Sustainability', new HtmlEditorField("Sustainability","GreyboxContent"));
   $fields->addFieldToTab('Root.Content.Diversity', new HtmlEditorField("Diversity","GreyboxContent"));

   return $fields;
}   

}

class InsidePage_Controller extends Page_Controller {

}
?>

I think the problem is happening when i add the HtmlEditorFields to the CMS because when I comment out those lines run a dev/build and reload the admin everything works just great. could someone help me with this?

/**
   $fields->addFieldToTab('Root.Content.StudentDevelopment', new HtmlEditorField("StudentDevelopment","GreyboxContent"));
   $fields->addFieldToTab('Root.Content.Sustainability', new HtmlEditorField("Sustainability","GreyboxContent"));
   $fields->addFieldToTab('Root.Content.Diversity', new HtmlEditorField("Diversity","GreyboxContent"));
**/

Avatar
socks

Community Member, 190 Posts

20 September 2009 at 10:46am

some inconsistencies (may or may not actually help)...
- Website not Webstie
- HTMLText not HTMlText
- HTMLEditorField not HtmlEditorField
- change your double quotes to single quotes

Also should some of those fields be Varchar instead of Text?

Avatar
Patrick Arlt

Community Member, 15 Posts

21 September 2009 at 6:08am

Tried all of those still no go. I would really like to get this fixed but I'm pretty new to Silverstripe and i wouldn't know how to tackle this.

Can anyone else take a stab at it?

Avatar
Patrick Arlt

Community Member, 15 Posts

22 September 2009 at 3:21pm

I guess I could supply a little more information.

Version: SS 2.3.3
Installed Modules: DataObjectManger, SIFR, and SWF Upload

I would really like to know what is wrong with my code, I've just started Silverstripe and love it and I would hate to have to use text area fields over HTMLEditorField.

Avatar
banal

Community Member, 901 Posts

22 September 2009 at 6:12pm

Edited: 22/09/2009 6:14pm

Did you really check the syntax on all items? It's HTMLText not HTMlText!
I copied your class, tidied up and it works... (I also used addFieldsToTab instead of addFieldToTab, it's easier to add multiple fields to one tab this way)

Here's the code: http://pastebin.com/m4bea5262

Update Oh yeah, and I changed your Text members to Varchar. If you really need more than 256 chars per field, you can change it back of course.