Jump to:

23454 Posts in 18904 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Error Saving Content with Html Editor Field

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

Page: 1
Go to End
Author Topic: 3075 Views
  • Patrick Arlt
    Avatar
    Community Member
    15 Posts

    Error Saving Content with Html Editor Field Link to this post

    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"));
    **/

  • socks
    Avatar
    Community Member
    190 Posts

    Re: Error Saving Content with Html Editor Field Link to this post

    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?

  • Patrick Arlt
    Avatar
    Community Member
    15 Posts

    Re: Error Saving Content with Html Editor Field Link to this post

    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?

  • Patrick Arlt
    Avatar
    Community Member
    15 Posts

    Re: Error Saving Content with Html Editor Field Link to this post

    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.

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Error Saving Content with Html Editor Field Link to this post

    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.

    3075 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.