Jump to:

5519 Posts in 1734 Topics by 1223 members

Customising the CMS

SilverStripe Forums » Customising the CMS » SS 3.0.2 - Multiple HTMLEditorField with different config

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

Page: 1
Go to End
Author Topic: 791 Views
  • ChanteLame
    Avatar
    Community Member
    3 Posts

    SS 3.0.2 - Multiple HTMLEditorField with different config Link to this post

    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.

  • suntrop
    Avatar
    Community Member
    131 Posts

    Re: SS 3.0.2 - Multiple HTMLEditorField with different config Link to this post

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

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