Třída TEdit je komponentou ke třídě TForm a je potomkem třídy TCheckBox. TEdit generuje HTML kód pro zobrazení editačního políčka pro vstup dat ve formuláři.
<?php
class TEdit extends TCheckBox {
protected $size = 30;
protected $maxlength = 30;
protected $visible = true;
protected $password = false;
protected $readonly = false;
public function __construct(){
$this->style = "TEdit";
}
public function SetSize($size){
$this->size = (int) $size;
}
public function SetMaxLen($maxlen){
$this->maxlength = (int) $maxlen;
}
public function SetVisible($visible=true){
$this->visible = (boolean) $visible;
}
public function SetPassword($password=false){
$this->password = (boolean) $password;
}
public function SetReadOnly($readonly=false){
$this->readonly = (boolean) $readonly;
}
public function Render(){
if ($this->name == "") throw new exception("Name is empty.");
if ($this->size > $this->maxlength) $this->maxlength = $this->size;
$type = "text";
if ($this->password) $type = "password";
if (!$this->visible) $type = "hidden";
if (($this->visible)and($this->TText_error)) $code .= $this->TText_error->Render();
$code .= "<INPUT type="$type" ";
if ($this->readonly) $code .= "readonly ";
$code .= "name="$this->name" value="$this->value" ";
if ($this->visible) $code .= "size="$this->size" maxlength="$this->maxlength" ";
if (($this->visible)and($this->alttext !="")) $code .= "title="$this->alttext" ";
if (($this->visible)and($this->readonly)) $code .= "READONLY ";
if (($this->visible)and($this->style !="")) $code .= "class="$this->style" ";
$code .= ">";
return $code;
}
}
?>