summaryrefslogtreecommitdiff
path: root/framework/Web/UI/TForm.php
diff options
context:
space:
mode:
authorxue <>2005-11-10 12:47:19 +0000
committerxue <>2005-11-10 12:47:19 +0000
commit55c4ac1bfe565f1ca7f537fdd8b7a201be28e581 (patch)
treea0599d5e36fdbb3f1e169ae56bab7d529597e3eb /framework/Web/UI/TForm.php
Initial import of prado framework
Diffstat (limited to 'framework/Web/UI/TForm.php')
-rw-r--r--framework/Web/UI/TForm.php128
1 files changed, 128 insertions, 0 deletions
diff --git a/framework/Web/UI/TForm.php b/framework/Web/UI/TForm.php
new file mode 100644
index 00000000..0edb976b
--- /dev/null
+++ b/framework/Web/UI/TForm.php
@@ -0,0 +1,128 @@
+<?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,'');
+ }
+}
+
+?> \ No newline at end of file