Skip to content

Commit

Permalink
[com_fields] Fix text-value being reverse for fields: list, radio, ch…
Browse files Browse the repository at this point in the history
…eckbox. Fix fields: radio, checkboxes not showing (#12739)

* Fix value-text being reverse for fields list, radio, checkbox, change 'name','key' label to be 'text' for these fields

* Fixed calling method from parent class

* Added missing layout file for radio field

* Fixed character '0' unusuable as field value

* Revert fix for zero character as value

* Proper variable names for view layouts of options-using fields

* They are options not just values

* JText the Text of options in the view layouts, since respective form fields do it already
  • Loading branch information
ggppdk authored and rdeutz committed Nov 7, 2016
1 parent 4caaa2b commit fc0fd25
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 23 deletions.
2 changes: 1 addition & 1 deletion administrator/language/en-GB/en-GB.com_fields.ini
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ COM_FIELDS_N_ITEMS_UPDATED="%d fields successfully updated in calendar %s"
COM_FIELDS_SYSTEM_PLUGIN_NOT_ENABLED="The <a href="_QQ_"%s"_QQ_">Fields System Plugin</a> is disabled. The custom fields will not display if you do not enable this plugin."
COM_FIELDS_TYPE_CALENDAR="Calendar"
COM_FIELDS_TYPE_CAPTCHA="CAPTCHA"
COM_FIELDS_TYPE_CHECKBOXES="Checkbox"
COM_FIELDS_TYPE_CHECKBOXES="Checkboxes"
COM_FIELDS_TYPE_COLOR="Colour"
COM_FIELDS_TYPE_EDITOR="Editor"
COM_FIELDS_TYPE_EMAIL="Email"
Expand Down
16 changes: 8 additions & 8 deletions administrator/language/en-GB/en-GB.lib_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ JLIB_FORM_FIELD_PARAM_CALENDAR_FORMAT_DESC="The date format to be used. This is
JLIB_FORM_FIELD_PARAM_CALENDAR_FORMAT_LABEL="Format"
JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_DESC="Allow multiple values to be selected."
JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_LABEL="Multiple"
JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_VALUES_DESC="The options of the list."
JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_VALUES_KEY_LABEL="Key"
JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_VALUES_LABEL="Checkbox Values"
JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_VALUES_DESC="The options of the checkbox list"
JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_VALUES_NAME_LABEL="Text"
JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_VALUES_LABEL="Checkbox options"
JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_VALUES_VALUE_LABEL="Value"
JLIB_FORM_FIELD_PARAM_EDITOR_BUTTONS_HIDE_DESC="Hide the buttons in the comma separated list."
JLIB_FORM_FIELD_PARAM_EDITOR_BUTTONS_HIDE_LABEL="Hide Buttons"
Expand All @@ -334,9 +334,9 @@ JLIB_FORM_FIELD_PARAM_INTEGER_STEP_LABEL="Step"
JLIB_FORM_FIELD_PARAM_LIST_MULTIPLE_DESC="Allow multiple values to be selected."
JLIB_FORM_FIELD_PARAM_LIST_MULTIPLE_LABEL="Multiple"
JLIB_FORM_FIELD_PARAM_LIST_MULTIPLE_VALUES_DESC="The options of the list."
JLIB_FORM_FIELD_PARAM_LIST_MULTIPLE_VALUES_LABEL="List Values"
JLIB_FORM_FIELD_PARAM_LIST_MULTIPLE_VALUES_LABEL="List options"
JLIB_FORM_FIELD_PARAM_LIST_MULTIPLE_VALUES_VALUE_LABEL="Value"
JLIB_FORM_FIELD_PARAM_LIST_MULTIPLE_VALUES_NAME_LABEL="Name"
JLIB_FORM_FIELD_PARAM_LIST_MULTIPLE_VALUES_NAME_LABEL="Text"
JLIB_FORM_FIELD_PARAM_MEDIA_IMAGE_CLASS_DESC="The class which is added to the image (src tag)."
JLIB_FORM_FIELD_PARAM_MEDIA_IMAGE_CLASS_LABEL="Image Class"
JLIB_FORM_FIELD_PARAM_MEDIA_PREVIEW_DESC="Shows or hides the preview of the selected image."
Expand All @@ -347,9 +347,9 @@ JLIB_FORM_FIELD_PARAM_MEDIA_HOME_LABEL="Home Directory"
JLIB_FORM_FIELD_PARAM_MEDIA_HOME_DESC="Should the directory with the files point to a user directory."
JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_DESC="Allow multiple values to be selected."
JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_LABEL="Multiple"
JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_VALUES_DESC="The options of the list."
JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_VALUES_KEY_LABEL="Key"
JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_VALUES_LABEL="Radio Values"
JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_VALUES_DESC="The options of the radio list."
JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_VALUES_NAME_LABEL="Text"
JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_VALUES_LABEL="Radio options"
JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_VALUES_VALUE_LABEL="Value"
JLIB_FORM_FIELD_PARAM_SQL_QUERY_DESC="The SQL query which will provide the data for the drop-down list. The query must return two columns; one called 'value' which will hold the values of the list items; the other called 'text' containing the text in the drop-down list."
JLIB_FORM_FIELD_PARAM_SQL_QUERY_LABEL="Query"
Expand Down
8 changes: 4 additions & 4 deletions components/com_fields/layouts/field/prepare/checkboxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@

$value = (array) $value;
$texts = array();
$options = JFormFieldList::getOptionsFromField($field);
$options = JFormAbstractlist::getOptionsFromField($field);

foreach ($options as $index => $optionsValue)
foreach ($options as $optionValue => $optionText)
{
if (in_array($index, $value))
if (in_array($optionValue, $value))
{
$texts[] = $optionsValue;
$texts[] = JText::_($optionText);
}
}

Expand Down
7 changes: 4 additions & 3 deletions components/com_fields/layouts/field/prepare/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
$texts = array();
$options = JFormAbstractlist::getOptionsFromField($field);

foreach ($options as $index => $optionsValue)
foreach ($options as $optionValue => $optionText)
{
if (in_array($index, $value))
if (in_array($optionValue, $value))
{
$texts[] = $optionsValue;
$texts[] = JText::_($optionText);
}
}


echo htmlentities(implode(', ', $texts));
37 changes: 37 additions & 0 deletions components/com_fields/layouts/field/prepare/radio.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_fields
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;

if (!key_exists('field', $displayData))
{
return;
}

$field = $displayData['field'];
$value = $field->value;

if (!$value)
{
return;
}

$value = (array) $value;
$texts = array();
$options = JFormAbstractlist::getOptionsFromField($field);

foreach ($options as $optionValue => $optionText)
{
if (in_array($optionValue, $value))
{
$texts[] = JText::_($optionText);
}
}


echo htmlentities(implode(', ', $texts));
6 changes: 3 additions & 3 deletions language/en-GB/en-GB.lib_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ JLIB_FORM_FIELD_PARAM_CALENDAR_FORMAT_LABEL="Format"
JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_DESC="Allow multiple values to be selected."
JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_LABEL="Multiple"
JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_VALUES_DESC="The options of the list."
JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_VALUES_KEY_LABEL="Key"
JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_VALUES_NAME_LABEL="Text"
JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_VALUES_LABEL="Checkbox Values"
JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_VALUES_VALUE_LABEL="Value"
JLIB_FORM_FIELD_PARAM_EDITOR_BUTTONS_HIDE_DESC="Hide the buttons in the comma separated list."
Expand All @@ -336,7 +336,7 @@ JLIB_FORM_FIELD_PARAM_LIST_MULTIPLE_LABEL="Multiple"
JLIB_FORM_FIELD_PARAM_LIST_MULTIPLE_VALUES_DESC="The options of the list."
JLIB_FORM_FIELD_PARAM_LIST_MULTIPLE_VALUES_LABEL="List Values"
JLIB_FORM_FIELD_PARAM_LIST_MULTIPLE_VALUES_VALUE_LABEL="Value"
JLIB_FORM_FIELD_PARAM_LIST_MULTIPLE_VALUES_NAME_LABEL="Name"
JLIB_FORM_FIELD_PARAM_LIST_MULTIPLE_VALUES_NAME_LABEL="Text"
JLIB_FORM_FIELD_PARAM_MEDIA_IMAGE_CLASS_DESC="The class which is added to the image (src tag)."
JLIB_FORM_FIELD_PARAM_MEDIA_IMAGE_CLASS_LABEL="Image Class"
JLIB_FORM_FIELD_PARAM_MEDIA_PREVIEW_DESC="Shows or hides the preview of the selected image."
Expand All @@ -348,7 +348,7 @@ JLIB_FORM_FIELD_PARAM_MEDIA_HOME_DESC="Should the directory with the files point
JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_DESC="Allow multiple values to be selected."
JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_LABEL="Multiple"
JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_VALUES_DESC="The options of the list."
JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_VALUES_KEY_LABEL="Key"
JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_VALUES_NAME_LABEL="Text"
JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_VALUES_LABEL="Radio Values"
JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_VALUES_VALUE_LABEL="Value"
JLIB_FORM_FIELD_PARAM_SQL_QUERY_DESC="The SQL query which will provide the data for the drop-down list. The query must return two columns; one called 'value' which will hold the values of the list items; the other called 'text' containing the text in the drop-down list."
Expand Down
4 changes: 2 additions & 2 deletions libraries/joomla/form/abstractlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ public static function getOptionsFromField($field)

if (isset($options->name))
{
foreach ($options->name as $index => $key)
foreach ($options->value as $index => $key)
{
$data[$key] = $options->value[$index];
$data[$key] = $options->name[$index];
}
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/form/parameters/checkboxes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<fieldset hidden="true" name="list_templates_modal" repeat="true">
<field
name="name"
label="JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_VALUES_KEY_LABEL"
label="JLIB_FORM_FIELD_PARAM_CHECKBOX_MULTIPLE_VALUES_NAME_LABEL"
size="30"
type="text"
/>
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/form/parameters/radio.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<fieldset hidden="true" name="list_templates_modal" repeat="true">
<field
name="name"
label="JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_VALUES_KEY_LABEL"
label="JLIB_FORM_FIELD_PARAM_RADIO_MULTIPLE_VALUES_NAME_LABEL"
size="30"
type="text"
/>
Expand Down

0 comments on commit fc0fd25

Please sign in to comment.