00001 <?php
00002
00014 class TKFormTable extends TKTable {
00020 public function __construct($action = "", $method = "post") {
00021 parent::__construct();
00022
00023 $this->addProperty('action', self::PROP_STRING);
00024 $this->addProperty('method', self::PROP_STRING);
00025
00026 $this->addProperty('form_class', self::PROP_CLASS);
00027 $this->addProperty('form_style', self::PROP_STYLE);
00028
00029 if($action == "")
00030 $action = $_SERVER['REQUEST_URI'];
00031 $this->set('action', $action);
00032 $this->set('method', $method);
00033 }
00034
00041 public function addInput($input, $label = "", $newRow = true) {
00042 if($newRow)
00043 $this->addRow();
00044 $this->add(new TKLabel($label));
00045 $this->add($input);
00046 }
00047
00053 public function addSubmit($name, $label) {
00054 $this->addRow();
00055 $this->addLabel(" ");
00056 $this->addRow();
00057 $this->addLabel("");
00058 $sub = new TKFormInput('submit', $name, $label);
00059 $this->add($sub);
00060 return $sub;
00061 }
00062
00064 protected function renderContainer($class, $style, $events, $id) {
00065 $collect = parent::renderContainer($class, $style, $events, " id=\"" . $this->getId() . "_table\"");
00066 $collect = "<form $id method=\"" . $this->get('method')
00067 . "\" action=\"" . $this->get('action')
00068 . "\" enctype=\"multipart/form-data\"$class[form]$style[form]$events>\n"
00069 . "$collect</form>\n";
00070 return $collect;
00071 }
00072
00074 public static function createFromXML($attrs, $contents, $node) {
00075 $action = isset($attrs['action']) ? $attrs['action'] : "";
00076 $method = isset($attrs['method']) ? $attrs['method'] : "post";
00077 unset($attrs['action']);
00078 unset($attrs['method']);
00079 $obj = new TKFormTable($action, $method);
00080 $children = $node['children'];
00081 self::convertStdAttributes($obj, $attrs);
00082 self::convertStdEvents($obj, $node);
00083 foreach($children as $child) {
00084 if($child['tag'] == 'row') {
00085 $obj->addRow();
00086 }
00087 else {
00088 $nobj = self::convertChild($child);
00089 if($nobj !== null)
00090 $obj->add($nobj);
00091 }
00092 }
00093
00094 return $obj;
00095 }
00096 }
00097
00098 ?>