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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
<?php
class TForm extends TControl
{
protected function onInit($param)
{
parent::onInit($param);
$this->getPage()->setForm($this);
}
protected function addAttributesToRender($writer)
{
$attributes=$this->getAttributes();
$writer->addAttribute('name',$this->getName());
$writer->addAttribute('method',$this->getMethod());
$writer->addAttribute('action',$this->getApplication()->getRequest()->getRequestURI());
$attributes->remove('name');
$attributes->remove('method');
$attributes->remove('action');
$page=$this->getPage();
/*
$onsubmit=$page->getClientOnSubmitEvent();
if($onsubmit!=='')
{
if(($existing=$attributes->itemAt('onsubmit'))!=='')
{
$page->getClientScript()->registerOnSubmitStatement('TForm:OnSubmitScript',$existing);
$attributes->remove('onsubmit');
}
if($page->getClientSupportsJavaScript())
$writer->addAttribute('onsubmit',$onsubmit);
}*/
if($this->getDefaultButton()!=='')
{//todo
$control=$this->findControl($this->getDefaultButton());
if(!$control)
$control=$page->findControl($this->getDefaultButton());
if($control instanceof IButtonControl)
$page->getClientScript()->registerDefaultButtonScript($control,$writer,false);
else
throw new Exception('Only IButtonControl can be default button.');
}
$writer->addAttribute('id',$this->getUniqueID());
foreach($attributes as $name=>$value)
$writer->addAttribute($name,$value);
}
/**
* @internal
*/
protected 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',$value,'post');
}
public function getEnctype()
{
return $this->getViewState('Enctype','');
}
public function setEnctype($value)
{
$this->setViewState('Enctype',$value,'');
}
public function getSubmitDisabledControls()
{
return $this->getViewState('SubmitDisabledControls',false);
}
public function setSubmitDisabledControls($value)
{
$this->setViewState('SubmitDisabledControls',TPropertyValue::ensureBoolean($value),false);
}
public function getName()
{
return $this->getUniqueID();
}
public function getTarget()
{
return $this->getViewState('Target','');
}
public function setTarget($value)
{
$this->setViewState('Target',$value,'');
}
}
?>
|