diff --git a/libraries/joomla/form/fields/checkboxes.php b/libraries/joomla/form/fields/checkboxes.php index f45679088d..ba52a91b2f 100644 --- a/libraries/joomla/form/fields/checkboxes.php +++ b/libraries/joomla/form/fields/checkboxes.php @@ -58,13 +58,55 @@ protected function getInput() // Get the field options. $options = $this->getOptions(); + // Get the value(s) + if (empty($this->value)) + { + // Filter the option using the preset flag + $filter = array_filter( + $options, + function($option) + { + return $option->preset; + } + ); + + // If the data exists or there is no preset + if ($this->form->existValue($this->fieldname, $this->group) || empty($filter)) + { + $filter = array_filter( + $options, + function($option) + { + return $option->default; + } + ); + } + + // Extract the values from the filter + $values = array_map( + function ($option) + { + return $option->value; + }, + $filter + ); + } + elseif (is_array($this->value)) + { + $values = $this->value; + } + else + { + $values = array($this->value); + } + // Build the checkbox field output. $html[] = '