Wrongly rendered option labels in form fields under some circumstances

From Joomla! Documentation

There is a known issue in form fields of type radio and list (presumably also others that extend the list field class) concerning option label translating.

Error reported

Option value label rendered incorrectly. Duplicate option labels.

Versions affected

Reported for Joomla 3.9.14 but older and newer versions are also affected for sure.

What is the cause


The field definition:

<field name="moderator" type="radio" label="COM_EXAMPLE_SPEAKER_TYPE">
    <option value="0">COM_EXAMPLE_SPEAKER</option>
    <option value="1">COM_EXAMPLE_SPEAKER_MODERATOR</option>

1) The name of the field is moderator.

2) Look at the language strings of the option labels:



3) At least the second one is present in a language ini file of the extension or otherwise loaded.

Resulting issue: The first one will lead to an error (= wrong option label) because Joomla magic is transforming it to COM_EXAMPLE_SPEAKER_MODERATOR while collecting the options for the output.

In other words: Joomla combines the language string COM_EXAMPLE_SPEAKER and the field name moderator to a wrong label COM_EXAMPLE_SPEAKER_MODERATOR because COM_EXAMPLE_SPEAKER_MODERATOR exists in the language ini file.

How to fix

Use another field name than moderator.


Use another language string than COM_EXAMPLE_SPEAKER_MODERATOR for option label.


Use another language string than COM_EXAMPLE_SPEAKER for option label.

More details

See https://github.com/joomla/joomla-cms/issues/27332