From 55c4ac1bfe565f1ca7f537fdd8b7a201be28e581 Mon Sep 17 00:00:00 2001 From: xue <> Date: Thu, 10 Nov 2005 12:47:19 +0000 Subject: Initial import of prado framework --- framework/Web/UI/TForm.php | 128 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 framework/Web/UI/TForm.php (limited to 'framework/Web/UI/TForm.php') 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 @@ +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 -- cgit v1.2.3