No Code Attached Yet J3 Issue
avatar marco-pistone
marco-pistone
21 Dec 2019

Steps to reproduce the issue

in my language file i have these labels

COM_MPROWBUILDER_TITLE_SPEAKER_TYPE = "Select a type"
COM_MPROWBUILDER_TITLE_SPEAKER = "Speaker"
COM_MPROWBUILDER_TITLE_MODERATOR = "Moderator"
COM_MPROWBUILDER_TITLE_SPEAKER_MODERATOR = "Speaker/Moderator"

this is my form file

<field name="moderator" 
                     filter="safehtml" type="radio" default="0" 
                     required="true"
                     class="btn-group"
                     label="COM_MPROWBUILDER_TITLE_SPEAKER_TYPE"
              >
                     <option value="1">COM_MPROWBUILDER_TITLE_MODERATOR</option>
                     <option value="0">COM_MPROWBUILDER_TITLE_SPEAKER</option>
                     <option value="2">COM_MPROWBUILDER_TITLE_SPEAKER_MODERATOR</option>
              </field>

Expected result

this is what i expect as result:
joom2

Actual result

instead i have this
joom1

System information (as much as possible)

Joomla 3.9.14
phph 7.3

Additional comments

This behaviour happens only with option labels
infact the label "COM_MPROWBUILDER_TITLE_SPEAKER_TYPE" is rendered correctly.
It seems a parsing mistake.
To avoid this i changed the label in COM_MPROWBUILDER_TITLE_SPEAKERMODERATOR so it works

avatar marco-pistone marco-pistone - open - 21 Dec 2019
avatar joomla-cms-bot joomla-cms-bot - change - 21 Dec 2019
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 21 Dec 2019
avatar marco-pistone marco-pistone - change - 21 Dec 2019
Title
Option Value Label read incorrectly
[3.9.14] Option Value Label rendered incorrectly
avatar marco-pistone marco-pistone - edited - 21 Dec 2019
avatar ReLater
ReLater - comment - 21 Dec 2019

Confirmed. Also with Joomla 3.9.13.

Image is with language debug activated. Strings in "en-GB.override.ini" (administrator).

21-12-_2019_19-36-45

avatar ReLater
ReLater - comment - 21 Dec 2019

Test with article.xml in Joomla 3.9.1. Seems to be OK there.

21-12-_2019_19-48-33

Looks like something happend between Joomla 3.9.1 and 3.9.13-

avatar ReLater
ReLater - comment - 21 Dec 2019

Test with Joomla 3.9.13 and "list" instead of "radio". Same issue:

21-12-_2019_19-54-41

avatar ReLater
ReLater - comment - 21 Dec 2019

I've found the resaon for your special case:
Your field name is "moderator".

In JFormField::getOptions() your label COM_MPROWBUILDER_TITLE_SPEAKER is sent through
Methode Text::alt()
See: https://github.com/joomla/joomla-cms/blob/3.9.14/libraries/joomla/form/fields/list.php#L158

which means in your case

JText::alt('COM_MPROWBUILDER_TITLE_SPEAKER', 'moderator')

These lines lead to the error:
https://github.com/joomla/joomla-cms/blob/3.9.14/libraries/src/Language/Text.php#L163-L166

which means in your case

if (Factory::getLanguage()->hasKey('COM_MPROWBUILDER_TITLE_SPEAKER' . '_' . 'Moderator'))
{
 $string .= '_' . 'Moderator';
}

COM_MPROWBUILDER_TITLE_SPEAKER becomes COM_MPROWBUILDER_TITLE_SPEAKER_MODERATOR
because there also exists a key COM_MPROWBUILDER_TITLE_SPEAKER_MODERATOR.

All I can say is "strange behavior" but don't know how to solve it ;-)

avatar alikon alikon - change - 26 Dec 2019
Labels Added: J3 Issue
avatar alikon alikon - labeled - 26 Dec 2019
avatar Quy
Quy - comment - 12 Mar 2020

Nice sleuthing! Looking at the examples in these lines, should $alt value be field and not dynamic values? It will fix in this instance, but I don't see a way to solve it either other than document it.

https://github.com/joomla/joomla-cms/blob/staging/libraries/src/Language/Text.php#L148-L149

avatar ReLater
ReLater - comment - 13 Mar 2020

I don't see a way to solve it either other than document it.

Documentation done: https://docs.joomla.org/Wrongly_rendered_option_labels_in_form_fields_under_some_circumstances

avatar ReLater
ReLater - comment - 13 Mar 2020

I did not test with Joomla 4. But I think it has the same issue after comparing the relevant classes:
https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Form/Field/ListField.php#L122

avatar brianteeman
brianteeman - comment - 23 Aug 2022

Based on the comments above and that this has been documented it should be closed

avatar zero-24 zero-24 - change - 23 Aug 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-08-23 13:39:22
Closed_By zero-24
Labels Added: No Code Attached Yet
Removed: ?
avatar zero-24 zero-24 - close - 23 Aug 2022

Add a Comment

Login with GitHub to post a comment