* @package tao */ class tao_helpers_form_elements_xhtml_Button extends tao_helpers_form_elements_Button { use XhtmlRenderingTrait; /** * * @var string */ protected $icon = ''; /** * * @var string */ protected $type = 'button'; /** * * @var string */ protected $iconPosition = ''; public function setIcon($icon, $position = 'before') { $this->icon = ''; $this->iconPosition = $position; } /** * Short description of method render * * @access public * @author Bertrand Chevrier, * @return string */ public function render() { $returnValue = $this->renderLabel(); $content = _dh($this->value); if ($this->icon) { $content = $this->iconPosition === 'before' ? $this->icon . ' ' . $content : $content . ' ' . $this->icon; } $returnValue .= "'; return $returnValue; } /** * Sets allowed by html5 buttons type * * @param string $type */ public function setType($type) { if ( in_array(strtolower($type), [ 'button', 'submit', 'reset']) ) { $this->type = $type; } } /** * Sets data-testid attribute * * @param string $testId */ public function setTestId($testId) { $this->setAttribute('data-testid', $testId); } }