Commit be24b5bf authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic
Browse files

Bug 1783685: Allow more than 1 TinyMCE field in the same pieform

behatnotneeded

Change-Id: I74a97ad84637e32dcc0463a968af09e77b891d0f
parent 09f8cbb4
......@@ -23,7 +23,7 @@ $_PIEFORM_WYSIWYGS = array();
*/
function pieform_element_wysiwyg(Pieform $form, $element) {
global $_PIEFORM_WYSIWYGS;
$_PIEFORM_WYSIWYGS[$form->get_name()] = $form->get_name() . '_' . $element['name'];
$_PIEFORM_WYSIWYGS[$form->get_name()][$element['name']] = $form->get_name() . '_' . $element['name'];
if (is_html_editor_enabled()) {
if (!$form->get_property('elementclasses')) {
$element['class'] = isset($element['class']) && $element['class'] !== '' ? $element['class'] . ' wysiwyg' : 'wysiwyg';
......@@ -85,18 +85,22 @@ function pieform_element_wysiwyg_get_headdata() {
. "\nvar editor_to_focus;"
. "\nPieformManager.connect('onsubmit', null, tinyMCE.triggerSave);"
. "\nPieformManager.connect('onload', null, function() {\n";
foreach ($_PIEFORM_WYSIWYGS as $name => $editor) {
foreach ($_PIEFORM_WYSIWYGS as $name => $editors) {
$result .= " if (!arguments[0] || arguments[0]=='{$name}') {\n";
$result .= " tinyMCE.execCommand('mceAddEditor', false, '$editor');\n";
$result .= " jQuery('#{$editor}').on('focus', function() {\n";
$result .= " editor_to_focus = '$editor';\n";
$result .= " });\n";
foreach($editors as $editorname => $editor) {
$result .= " tinyMCE.execCommand('mceAddEditor', false, '$editor');\n";
$result .= " jQuery('#{$editor}').on('focus', function() {\n";
$result .= " editor_to_focus = '$editor';\n";
$result .= " });\n";
}
$result .= " };\n";
}
$result .= "});\nPieformManager.connect('onreply', null, function() {\n";
foreach ($_PIEFORM_WYSIWYGS as $name => $editor) {
foreach ($_PIEFORM_WYSIWYGS as $name => $editors) {
$result .= " if (!arguments[0] || arguments[0]=='{$name}') {\n";
$result .= " tinyMCE.execCommand('mceRemoveEditor', false, '$editor');\n";
foreach($editors as $editorname => $editor) {
$result .= " tinyMCE.execCommand('mceRemoveEditor', false, '$editor');\n";
}
$result .= " };\n";
}
$result .= "});</script>";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment