Třída TCheckBox je komponentou ke třídě TForm a je potomkem třídy TText. TCheckBox generuje HTML kód pro zobrazení zaškrtávacího políčka (ano/ne) ve formuláři.
<?php
class TCheckBox extends TText {
protected $readonly = false;
protected $TText_error;
protected $alttext;
public function __construct(){
$this->style = "TCheckBox";
}
public function SetReadOnly($readonly=false){
$this->readonly = (boolean) $readonly;
}
public function SetError(TText $o_error){
$this->TText_error = $o_error;
}
public function SetAltText($alttext){
$this->alttext = trim($alttext);
}
public function Render(){
if ($this->name == "") throw new exception("Name is empty.");
if ($this->TText_error) $code .= $this->TText_error->Render();
$code .= "<INPUT type="checkbox" ";
if ($this->readonly) $code .= "readonly ";
$code .= "name="$this->name" value="on" ";
if ($this->value =="on") $code .= "checked ";
if ($this->alttext !="") $code .= "title="$this->alttext" ";
if ($this->style !="") $code .= "class="$this->style" ";
$code .= ">";
return $code;
}
}
?>