No Code Attached Yet bug
avatar Denitz
Denitz
5 Jan 2022

Steps to reproduce the issue

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.

Expected result

Button actions should be executed separately for each editor instance.

Actual result

Button actions are executed on first field only.

System information (as much as possible)

Both Joomla 3 and 4 are affected.

avatar Denitz Denitz - open - 5 Jan 2022
avatar joomla-cms-bot joomla-cms-bot - change - 5 Jan 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 5 Jan 2022
avatar dgrammatiko
dgrammatiko - comment - 5 Jan 2022

Now we have two fields with the name articletext

You CANNOT have 2 fields with the same name

avatar Denitz
Denitz - comment - 5 Jan 2022

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);

``

avatar Chaosxmk
Chaosxmk - comment - 5 Jan 2022

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?

avatar Hackwar Hackwar - change - 17 Feb 2023
Labels Added: bug
avatar Hackwar Hackwar - labeled - 17 Feb 2023
avatar brianteeman
brianteeman - comment - 29 Aug 2025

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.

avatar Fedik Fedik - close - 29 Aug 2025
avatar Fedik Fedik - change - 29 Aug 2025
Status New Closed
Closed_Date 0000-00-00 00:00:00 2025-08-29 09:08:58
Closed_By Fedik
avatar brianteeman
brianteeman - comment - 29 Aug 2025

@Fedik please check because in my test the problem still existed

avatar Fedik
Fedik - comment - 29 Aug 2025

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

avatar brianteeman
brianteeman - comment - 29 Aug 2025

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

avatar Fedik
Fedik - comment - 29 Aug 2025

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

Add a Comment

Login with GitHub to post a comment