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.

Customising the CMS

SS 3.0.2 - Multiple HTMLEditorField with different config


Reply

2 Posts   836 Views

Avatar
ChanteLame

3 January 2013 at 5:42am (Last edited: 3 January 2013 5:44am), Community Member, 3 Posts

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

20 May 2013 at 11:03pm Community Member, 131 Posts

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