There are new custom field types (audio, video, document). When I create a new field, chose one of the new types and change it again before saving, the initial type is kept.
The field view still shows the type "audio" with follow-up errors, such as not being able to chose video formats
6.1
Select videos in the article's field.
Only audio files can be selected.
No response
The problem is the hidded types field
https://github.com/joomla/joomla-cms/blob/6.1-dev/plugins/fields/media/params/audio.xml#L33-L37
When the type is switched, the default value is kept.
| Labels |
Added:
bug
|
||
| Labels |
Added:
No Code Attached Yet
|
||
Thanks. Confirmed.
I can reproduce this.
@sergeytolkachyov can you have a look
It is not only these two fields. Same happens with for example images list and radio field, probably also in J5.4
@sergeytolkachyov can you have a look
Codex AI found this:
Summary
The problem in Joomla 6 is not in article rendering itself, but in the fact that when the type of a new custom field is changed, core never normalises jform[fieldparams] against the schema of the new type. Old keys remain in the data flow, and then com_fields only knows how to:
fieldparams that happen to survive,fieldparams into real XML attributes of the field on the article form, without a whitelist.That is why the UI already shows the second type, while some parameters of the first type continue to exist underneath.
Separately: in Joomla 6 core this is not AJAX. Changing the type performs a normal form submit with task=field.reload: admin-field-typehaschanged.js#L7.
Bug Data Flow
The user selects the first type, for example imagelist.
File: admin-field-typehaschanged.js#L7
Here element.form.submit() is executed with task=field.reload.
In reload(), the controller takes the entire jform payload as-is.
File: FormController.php#L801
Key points:
Calendar: FormController.php#L846$data array is written into session state: FormController.php#L869This is the primary defect in the flow: reload() does not clean fieldparams against the new type.
So if fieldparams from imagelist were present before the second type change, they come back as the live form data.
getFormPath(...)load(file_get_contents($path), true, '/form/*')Important: this loads the new type schema, but it does not purge the old fieldparams.
FieldTable::bind() serialises them as-is.subform, and then:loadArray($src['fieldparams']): FieldTable.php#L108com_fields merges those parameters back into the field type again.This is where the bug becomes visible in the article form.
How It Looks In The imagelist -> radio Case
imagelist step, the form contains, for example:fieldparams[directory]fieldparams[multiple]fieldparams[image_class]Schema: imagelist.xml
The user does not save, but changes the type to radio.
At the moment of submit, the current form is still the imagelist form, so the old fieldparams[*] are submitted to field.reload.
reload() stores them in session state together with the already changed type=radio.
For radio, the UI is rebuilt using the radio schema:
radio.xml
But this does not mean the old keys have been removed at the data level.
fieldparams, then when the field is built on the article form:FieldsPlugin::onCustomFieldsPrepareDom() performs the merge,<field ...> may again receive directory, multiple, image_class, and other foreign attributes.For radio, this is particularly visible because some foreign attributes affect the resulting DOM even though they do not exist in radio.xml.
Why The Bug Appears "Random"
Root Cause
The root cause is not a single method, but a broken invariant in the flow:
type changed
-> old fieldparams are not purged
-> the new XML schema is only loaded on top
-> at save time there is no mandatory server-side sanitisation of fieldparams against the current type schema
-> at render time all stored scalar fieldparams are turned back into XML attributes
In short: after a type change, Joomla changes the form, but it does not rebuild the field data to match the new type.
What I Would Consider The Correct Fix
There are two realistic places to fix this properly:
reload(), rebuild fieldparams against the new type form before writing to setUserState().FieldModel/FieldTable, enforce a strict server-side filter of fieldparams against the XML definition of the current field type before bind() / save.The second option is more reliable, because it fixes not only the UI transition case, but the data model itself.
| Status | New | ⇒ | Closed |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2026-03-25 10:03:19 |
| Closed_By | ⇒ | HLeithner |
Confirmed