Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » HTML Field

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 2354 Views
  • SheaDawson
    Avatar
    Community Member
    45 Posts

    HTML Field Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: HTML Field Link to this post

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

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

  • SheaDawson
    Avatar
    Community Member
    45 Posts

    Re: HTML Field Link to this post

    Outstanding! Thank you

  • spierala
    Avatar
    Community Member
    80 Posts

    Re: HTML Field Link to this post

    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

  • neilcreagh
    Avatar
    Community Member
    88 Posts

    Re: HTML Field Link to this post

    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.

    2354 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.