If a form has multiple editor fields with the same name but within different groups, all XTD button actions are applied in first editor only.
I.e. in item has top-level field <field name="description" type="editor"...
+ a field with the same name
but inside the another group like <fields name="params"> <field name="description" type="editor"...
If you click any XTD buttons in the editor field of params
group, all actions are actually applied in the first field.
I.e. Readmore is inserted in the first field etc.
Test:
Edit admin article.xml form of com_content and add these code after <fieldset name="basic" ...
line:
<field
name="articletext"
type="editor"
label="COM_CONTENT_FIELD_ARTICLETEXT_LABEL"
description="COM_CONTENT_FIELD_ARTICLETEXT_DESC"
filter="JComponentHelper::filterText"
buttons="true"
/>
Now we have two fields with the name articletext
, the first one is original article text in Content tab, the second one is displayed in Options tab and has the field group attribs
, these are two different fields even with the same name
attribute.
Try to use any buttons in this second field, see that actually all actions are applied in the main editor field displayed in Content tab.
Button actions should be executed separately for each editor instance.
Button actions are executed on first field only.
Both Joomla 3 and 4 are affected.
Labels |
Added:
No Code Attached Yet
|
No, it's possible in JForm if the fields have different groups.
The issue is with the TinyMCE plugin code which doesn't use the field ID but only last part of field name to identify the editor instance:
$id = preg_replace('/(\s|[^A-Za-z0-9_])+/', '_', $id);
$nameGroup = explode('[', preg_replace('/\[\]|\]/', '', $name));
$fieldName = end($nameGroup);
``
No, it's possible in JForm if the fields have different groups.
The issue is with the TinyMCE plugin code which doesn't use the field ID but only last part of field name to identify the editor instance:
$id = preg_replace('/(\s|[^A-Za-z0-9_])+/', '_', $id); $nameGroup = explode('[', preg_replace('/\[\]|\]/', '', $name)); $fieldName = end($nameGroup);
As weird as it is to want to do, it is perfectly valid HTML to run fields with names like "fieldset[fieldName]" and "fieldset2[fieldName]".
Should $fieldName
be modified to prepend it's fieldset's name?
Labels |
Added:
bug
|
The proposed change was rejected as it broke backwards compatibility etc. I really dont see the need for a code change - just use unique fieldnames as explained above.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2025-08-29 09:08:58 |
Closed_By | ⇒ | Fedik |
It is fixed in 5.0. Other editors should support new API to work properly.
Ah okay, I missed "the same name" part.
The only thing is the editor parameters are linked to the field name, so here yes, only way is to use different editor name when need different parameters
The buttons works correctly, even when the editor name is the same the button will insert content in to correct editor instance
The buttons works correctly, even when the editor name is the same the button will insert content in to correct editor instance
No - they insert the content/link/image etc in one of the editors. Not necessarily the correct one. In my tests they were always inserted in the second editor
Hm are you sure, can you provide the details how did you test?
I checked on 6.0, in Custom HTML module with subform:
<field type="subform" name="subform" label="subform" multiple="true">
<form>
<field type="editor" name="content" label="Editor" buttons="true"/>
</form>
</field>
So there multiple editors with "content" name + main editor with name "content".
You CANNOT have 2 fields with the same name