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

SS 3.0.2 - Multiple HTMLEditorField with different config


Go to End


2 Posts   2102 Views

Avatar
ChanteLame

Community Member, 3 Posts

3 January 2013 at 5:42am

Edited: 03/01/2013 5:44am

Hello,
I am trying to add two HTMLEditor with two different configs. It's seems like the HTMLEditor config is static and only the last active config is apply.

Here my code :

<?php // File : /mysite/NewsItem.php
class NewsItem extends DataObject{
      static $db = array("Titre"  => "HTMLText",
                         "Info"   => "HTMLText");
      static $has_one = array("News" => "News");
       public function getCMSFields(){
              $fields = new FieldList();
              HtmlEditorConfig::set_active("cms");
              $fields->push(HtmlEditorField::create("Titre", "Titre français")
                        ->setRows(10));
        
              HtmlEditorConfig::set_active("reduced");
              $fields->push(HtmlEditorField::create("Info", "Plus d'info")
                        ->setRows(10));
              return $fields;
       }
}

And my _config.php :

<?php
/*... some code ... */

$reduced = HtmlEditorConfig::get('reduced');
$reduced->disablePlugins('table'); 
$reduced->setButtonsForLine(1, 
    'bold','italic','underline','strikethrough','separator', 
    'formatselect','separator', 
    'bullist','numlist','hr','charmap' 
); 
$reduced->setButtonsForLine(2); 
$reduced->setButtonsForLine(3);
$reduced->setOptions(array("width"           => "80%",
                           "priority"        => 1));


$cms = HtmlEditorConfig::get('cms');
$cms->setOptions(array("width"           => "80%",
                       "priority"        => 1));

With this, both HTMLEditorField are in "reduced" mode...

I am using the 3.0.2 version. I've carfully read the docs of HtmlEditorConfig, and I cannot see my mistake.
Thanks for your help.
H.

Avatar
suntrop

Community Member, 141 Posts

20 May 2013 at 11:03pm

Hi ChanteLame. Have you found a solution? I've got the same problem: two editors but both use the latest config.