Back to FormField class

Method renderDataAttributes

public string
renderDataAttributes
()
Method to render data attributes to html.
Returns
  • string A HTML Tag Attribute string of data attribute(s)
Since
  • 4.0.0
Class: FormField
Project: Joomla

Method renderDataAttributes - Source code

/**
 * Method to render data attributes to html.
 *
 * @return  string  A HTML Tag Attribute string of data attribute(s)
 *
 * @since  4.0.0
 */
public function renderDataAttributes()
{
    $dataAttribute = '';
    $dataAttributes = $this->getDataAttributes();
    if (!empty($dataAttributes)) {
        foreach ($dataAttributes as $key => $attrValue) {
            $dataAttribute .= ' ' . $key . '="' . htmlspecialchars($attrValue, ENT_COMPAT, 'UTF-8') . '"';
        }
    }
    return $dataAttribute;
}