From a953c793fb6f5f694edc778c6ff6079d8c6aeeea Mon Sep 17 00:00:00 2001 From: Brian Teeman Date: Wed, 3 Apr 2019 13:04:05 +0100 Subject: [PATCH] none config --- .../components/com_content/forms/article.xml | 1 + layouts/joomla/form/field/radio/switcher.php | 185 +++++++++--------- libraries/src/Form/FormField.php | 2 +- 3 files changed, 94 insertions(+), 94 deletions(-) diff --git a/administrator/components/com_content/forms/article.xml b/administrator/components/com_content/forms/article.xml index 0684232883feb..fef4a86b2d6df 100644 --- a/administrator/components/com_content/forms/article.xml +++ b/administrator/components/com_content/forms/article.xml @@ -224,6 +224,7 @@ type="radio" label="JFEATURED" class="switcher" + required="true" default="0" > diff --git a/layouts/joomla/form/field/radio/switcher.php b/layouts/joomla/form/field/radio/switcher.php index 05f73c9219c4c..b630f7fe0bfbe 100644 --- a/layouts/joomla/form/field/radio/switcher.php +++ b/layouts/joomla/form/field/radio/switcher.php @@ -9,9 +9,9 @@ defined('JPATH_BASE') or die; -use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper; -extract($displayData); +extract($displayData, null); /** * Layout variables @@ -55,31 +55,51 @@ * %3 - value * %4 = any other attributes */ -$format = ''; -$alt = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $name); +$input = ''; +$alt = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $name); -?> - -
- - > - -
- - $option) : ?> - value === $value) ? 'checked="checked"' : ''; - $optionClass = !empty($option->class) ? 'class="' . $option->class . '"' : ''; - $disabled = !empty($option->disable) || ($disabled && !$checked) ? 'disabled' : ''; - - // Initialize some JavaScript option attributes. - $onclick = !empty($option->onclick) ? 'onclick="' . $option->onclick . '"' : ''; - $onchange = !empty($option->onchange) ? 'onchange="' . $option->onchange . '"' : ''; - $oid = $id . $i; - $ovalue = htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8'); - $attributes = array_filter(array($checked, $optionClass, $disabled, $onchange, $onclick)); - ?> - - - -
- - -
- - - - - -
-
\ No newline at end of file +
+ + + +
+ $option) : ?> + value == $value) ? 'checked="checked"' : ''; + $active = ((string) $option->value == $value) ? 'class="active"' : ''; + + // Initialize some option attributes. + $oid = $id . $i; + $ovalue = htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8'); + $attributes = array_filter(array($checked, $active, null)); + $text = $options[$i]->text; + ?> + + ' . $text . ''; ?> + + +
+
diff --git a/libraries/src/Form/FormField.php b/libraries/src/Form/FormField.php index 4ce7d5b10ce52..c7dd92429f9cd 100644 --- a/libraries/src/Form/FormField.php +++ b/libraries/src/Form/FormField.php @@ -948,7 +948,7 @@ public function renderField($options = array()) $options['rel'] = ''; - if (empty($options['hiddenLabel']) && $this->getAttribute('hiddenLabel')) + if (empty($options['hiddenLabel']) && $this->getAttribute('hiddenLabel') || $this->class === 'switcher') { $options['hiddenLabel'] = true; }