Back to FormField class

Method renderField

public string
renderField
(mixed $options = array())
Method to get a control group with label and input.
Parameters
  • array $options Options to be passed into the rendering of the field
Returns
  • string A string containing the html for the control group
Since
  • 3.2
Class: FormField
Project: Joomla

Method renderField - Source code

/**
 * Method to get a control group with label and input.
 *
 * @param   array  $options  Options to be passed into the rendering of the field
 *
 * @return  string  A string containing the html for the control group
 *
 * @since   3.2
 */
public function renderField($options = array())
{
    if ($this->hidden) {
        return $this->getInput();
    }
    if (!isset($options['class'])) {
        $options['class'] = '';
    }
    $options['rel'] = '';
    if (empty($options['hiddenLabel'])) {
        if ($this->getAttribute('hiddenLabel')) {
            $options['hiddenLabel'] = $this->getAttribute('hiddenLabel') == 'true';
        } else {
            $options['hiddenLabel'] = $this->hiddenLabel;
        }
    }
    if (empty($options['hiddenDescription'])) {
        if ($this->getAttribute('hiddenDescription')) {
            $options['hiddenDescription'] = $this->getAttribute('hiddenDescription') == 'true';
        } else {
            $options['hiddenDescription'] = $this->hiddenDescription;
        }
    }
    if (empty($options['inlineHelp'])) {
        if ($this->getAttribute('inlineHelp')) {
            $options['inlineHelp'] = $this->getAttribute('inlineHelp') == 'true';
        } else {
            $options['inlineHelp'] = isset($this->form->getXml()->config->inlinehelp['button']) ? (string) $this->form->getXml()->config->inlinehelp['button'] == 'show' ?: false : $this->inlineHelp;
        }
    }
    if ($this->showon) {
        $options['rel'] = ' data-showon=\'' . json_encode(FormHelper::parseShowOnConditions($this->showon, $this->formControl, $this->group)) . '\'';
        $options['showonEnabled'] = true;
    }
    $data = array('input' => $this->getInput(), 'label' => $this->getLabel(), 'options' => $options);
    $data = array_merge($this->getLayoutData(), $data);
    return $this->getRenderer($this->renderLayout)->render($data);
}