Back to PredefinedlistField class

Method getOptions

protected array
getOptions
()
Method to get the options to populate list
Returns
  • array The field option objects.
Since
  • 3.2

Method getOptions - Source code

/**
 * Method to get the options to populate list
 *
 * @return  array  The field option objects.
 *
 * @since   3.2
 */
protected function getOptions()
{
    // Hash for caching
    $hash = md5($this->element);
    $type = strtolower($this->type);
    if (!isset(static::$options[$type][$hash]) && !empty($this->predefinedOptions)) {
        static::$options[$type][$hash] = parent::getOptions();
        $options = array();
        foreach ($this->predefinedOptions as $value => $text) {
            $val = (string) $value;
            if (empty($this->optionsFilter) || in_array($val, $this->optionsFilter, true)) {
                $text = $this->translate ? Text::_($text) : $text;
                $options[] = (object) array('value' => $value, 'text' => $text);
            }
        }
        static::$options[$type][$hash] = array_merge(static::$options[$type][$hash], $options);
    }
    return static::$options[$type][$hash];
}