diff --git a/libraries/joomla/form/fields/number.php b/libraries/joomla/form/fields/number.php index 5844c9e6eb16e..c6c55ec63ebb2 100644 --- a/libraries/joomla/form/fields/number.php +++ b/libraries/joomla/form/fields/number.php @@ -143,6 +143,41 @@ public function setup(SimpleXMLElement $element, $value, $group = null) */ protected function getInput() { + if ($this->element['useglobal']) + { + $component = JFactory::getApplication()->input->getCmd('option'); + + // Get correct component for menu items + if ($component == 'com_menus') + { + $link = $this->form->getData()->get('link'); + $uri = new JUri($link); + $component = $uri->getVar('option', 'com_menus'); + } + + $params = JComponentHelper::getParams($component); + $value = $params->get($this->fieldname); + + // Try with global configuration + if (is_null($value)) + { + $value = JFactory::getConfig()->get($this->fieldname); + } + + // Try with menu configuration + if (is_null($value) && JFactory::getApplication()->input->getCmd('option') == 'com_menus') + { + $value = JComponentHelper::getParams('com_menus')->get($this->fieldname); + } + + if (!is_null($value)) + { + $value = (string) $value; + + $this->hint = JText::sprintf('JGLOBAL_USE_GLOBAL_VALUE', $value); + } + } + // Trim the trailing line in the layout file return rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()), PHP_EOL); }