1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
<?php
/**
* TForm class file
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
* @copyright Copyright © 2005 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Revision: $ $Date: $
* @package System.Web.UI
*/
/**
* TForm class
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Web.UI
* @since 3.0
*/
class TForm extends TControl
{
/**
* Registers the form with the page.
* @param mixed event parameter
*/
public function onInit($param)
{
parent::onInit($param);
$this->getPage()->setForm($this);
}
protected function addAttributesToRender($writer)
{
$writer->addAttribute('id',$this->getClientID());
$writer->addAttribute('method',$this->getMethod());
$writer->addAttribute('action',$this->getRequest()->getRequestURI());
if(($enctype=$this->getEnctype())!=='')
$writer->addAttribute('enctype',$enctype);
$attributes=$this->getAttributes();
$attributes->remove('action');
$writer->addAttributes($attributes);
if(($butt=$this->getDefaultButton())!=='')
{
if(($button=$this->findControl($butt))!==null)
$this->getPage()->getClientScript()->registerDefaultButton($this,$button);
else
throw new TInvalidDataValueException('form_defaultbutton_invalid',$butt);
}
}
/**
* @internal
*/
public function render($writer)
{
$this->addAttributesToRender($writer);
$writer->renderBeginTag('form');
$page=$this->getPage();
$page->beginFormRender($writer);
$this->renderChildren($writer);
$page->endFormRender($writer);
$writer->renderEndTag();
}
public function getDefaultButton()
{
return $this->getViewState('DefaultButton','');
}
public function setDefaultButton($value)
{
$this->setViewState('DefaultButton',$value,'');
}
public function getDefaultFocus()
{
return $this->getViewState('DefaultFocus','');
}
public function setDefaultFocus($value)
{
$this->setViewState('DefaultFocus',$value,'');
}
public function getMethod()
{
return $this->getViewState('Method','post');
}
public function setMethod($value)
{
$this->setViewState('Method',TPropertyValue::ensureEnum($value,'post','get'),'post');
}
public function getEnctype()
{
return $this->getViewState('Enctype','');
}
public function setEnctype($value)
{
$this->setViewState('Enctype',$value,'');
}
public function getName()
{
return $this->getUniqueID();
}
}
?>
|