Back to UserField class

Method getLayoutData

public array
getLayoutData
()
Get the data that is going to be passed to the layout
Returns
  • array
Since
  • 3.5
Class: UserField
Project: Joomla

Method getLayoutData - Source code

/**
 * Get the data that is going to be passed to the layout
 *
 * @return  array
 *
 * @since   3.5
 */
public function getLayoutData()
{
    // Get the basic field data
    $data = parent::getLayoutData();
    // Initialize value
    $name = Text::_('JLIB_FORM_SELECT_USER');
    if (is_numeric($this->value)) {
        $name = User::getInstance($this->value)->name;
    } elseif (strtoupper($this->value) === 'CURRENT') {
        // 'CURRENT' is not a reasonable value to be placed in the html
        $current = Factory::getUser();
        $this->value = $current->id;
        $data['value'] = $this->value;
        $name = $current->name;
    }
    // User lookup went wrong, we assign the value instead.
    if ($name === null && $this->value) {
        $name = $this->value;
    }
    $extraData = array('userName' => $name, 'groups' => $this->getGroups(), 'excluded' => $this->getExcluded());
    return array_merge($data, $extraData);
}