FOF30\Form\Field\UserGroup::getStatic PHP Method

getStatic() public method

Get the rendering of this field type for static display, e.g. in a single item view (typically a "read" task).
Since: 2.0
public getStatic ( ) : string
return string The field HTML
    public function getStatic()
    {
        if (isset($this->element['legacy'])) {
            return $this->getInput();
        }
        $class = $this->class ? ' class="' . $this->class . '"' : '';
        $params = $this->getOptions();
        $db = $this->form->getContainer()->platform->getDbo();
        $query = $db->getQuery(true)->select('a.id AS value, a.title AS text')->from('#__usergroups AS a')->group('a.id, a.title')->order('a.id ASC')->order($db->qn('title') . ' ASC');
        // Get the options.
        $options = $db->setQuery($query)->loadObjectList();
        // If params is an array, push these options to the array
        if (is_array($params)) {
            $options = array_merge($params, $options);
        } elseif ($params) {
            array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_ACCESS_SHOW_ALL_LEVELS')));
        }
        return '<span id="' . $this->id . '" ' . $class . '>' . htmlspecialchars(GenericList::getOptionName($options, $this->value), ENT_COMPAT, 'UTF-8') . '</span>';
    }