public function render($writer)
{
$this->getPage()->ensureRenderInForm($this);
if ($this->getHasStyle()) {
$this->getStyle()->addAttributesToRender($writer);
}
if (($tooltip = $this->getToolTip()) !== '') {
$writer->addAttribute('title', $tooltip);
}
if ($this->getHasAttributes()) {
$attributes = $this->getAttributes();
$value = $attributes->remove('value');
// onclick js should only be added to input tag
if (($onclick = $attributes->remove('onclick')) === null) {
$onclick = '';
}
if ($attributes->getCount()) {
$writer->addAttributes($attributes);
}
if ($value !== null) {
$attributes->add('value', $value);
}
} else {
$onclick = '';
}
if ($needspan = $this->getSpanNeeded()) {
$writer->addAttribute('id', $this->getSurroundingTagID());
$writer->renderBeginTag($this->getSurroundingTag());
}
$clientID = $this->getClientID();
if (($text = $this->getText()) !== '') {
if ($this->getTextAlign() === TTextAlign::Left) {
$this->renderLabel($writer, $clientID, $text);
$this->renderInputTag($writer, $clientID, $onclick);
} else {
$this->renderInputTag($writer, $clientID, $onclick);
$this->renderLabel($writer, $clientID, $text);
}
} else {
$this->renderInputTag($writer, $clientID, $onclick);
}
if ($needspan) {
$writer->renderEndTag();
}
}