Some further refactoring in form classes.
[timetracker.git] / WEB-INF / lib / form / TextField.class.php
index a409410..044b3d6 100644 (file)
 // +----------------------------------------------------------------------+
 
 import('form.FormElement');
-       
+
 class TextField extends FormElement {
-    var $mValue;
-    var $mPassword     = false;
-    var $cClassName            = "TextField";
 
-       function __construct($name,$value="")
-       {
-               $this->mName                    = $name;
-               $this->mValue                   = $value;
-       }
-       
-       function setAsPassword($name)   { $this->mPassword = $name;     }
-       function getAsPassword()        { return $this->mPassword; }
+  function __construct($name, $value = '')
+  {
+    $this->class = 'TextField';
+    $this->name = $name;
+    $this->value = $value;
+  }
 
-       function toStringControl()      {
-               if (!$this->isRenderable()) return "";
-           
-               if (!$this->isEnable()) {
-                       $html = "<input name=\"$this->mName\" value=\"".htmlspecialchars($this->getValue())."\" readonly>\n";  
+  // TODO: refactoring ongoing down from here.
+       function getHtml() {
+               if (!$this->isEnabled()) {
+                       $html = "<input name=\"$this->name\" value=\"".htmlspecialchars($this->getValue())."\" readonly>\n";
                } else {
                        
-                   if ($this->mId=="") $this->mId = $this->mName;
+                   if ($this->id=="") $this->id = $this->name;
                    
-                       $html = "\n\t<input";
-                       $html .= ( $this->mPassword ? " type=\"password\"" : " type=\"text\"");
-                       $html .= " name=\"$this->mName\" id=\"$this->mId\"";
+                       $html = "\n\t<input type=\"text\"";
+                       $html .= " name=\"$this->name\" id=\"$this->id\"";
                        
-                       if ($this->mSize!="")
-                         $html .= " size=\"$this->mSize\"";
+                       if ($this->size!="")
+                         $html .= " size=\"$this->size\"";
                          
-                       if ($this->mStyle!="")
-                          $html .= " style=\"$this->mStyle\"";
+                       if ($this->style!="")
+                          $html .= " style=\"$this->style\"";
                          
-                       if ($this->mMaxLength!="")
-                          $html .= " maxlength=\"$this->mMaxLength\"";
+                       if ($this->max_length!="")
+                          $html .= " maxlength=\"$this->max_length\"";
                           
-                       if ($this->mOnChange!="")
-                          $html .= " onchange=\"$this->mOnChange\"";
+                       if ($this->on_change!="")
+                          $html .= " onchange=\"$this->on_change\"";
 
                        $html .= " value=\"".htmlspecialchars($this->getValue())."\"";
                        $html .= ">";