Back to ToolbarButton class

Method renderButton

protected string
renderButton
(array &$options)
Render button HTML.
Parameters
  • array & $options The button options.
Returns
  • string The button HTML.
Since
  • 4.0.0
Class: ToolbarButton
Project: Joomla

Method renderButton - Source code

/**
 * Render button HTML.
 *
 * @param   array  &$options  The button options.
 *
 * @return  string  The button HTML.
 *
 * @since   4.0.0
 */
protected function renderButton(array &$options) : string
{
    $this->prepareOptions($options);
    // Prepare custom attributes.
    unset($options['attributes']['id'], $options['attributes']['class']);
    $options['htmlAttributes'] = ArrayHelper::toString($options['attributes']);
    // Isolate button class from icon class
    $buttonClass = str_replace('icon-', '', $this->getName());
    $iconclass = $options['btnClass'] ?? '';
    $options['btnClass'] = 'button-' . $buttonClass . ' ' . $iconclass;
    // Instantiate a new LayoutFile instance and render the layout
    $layout = new FileLayout($this->layout);
    return $layout->render($options);
}