From fb2ba05edf43665152150f65731a80ecb327b5da Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 19 Feb 2006 05:10:07 +0000 Subject: Made TForm DefaultButton working. --- framework/Web/UI/TForm.php | 60 ++++++++++------------------------------------ 1 file changed, 13 insertions(+), 47 deletions(-) (limited to 'framework/Web/UI/TForm.php') diff --git a/framework/Web/UI/TForm.php b/framework/Web/UI/TForm.php index 1a6cc21a..538cf8cd 100644 --- a/framework/Web/UI/TForm.php +++ b/framework/Web/UI/TForm.php @@ -20,6 +20,10 @@ */ class TForm extends TControl { + /** + * Registers the form with the page. + * @param mixed event parameter + */ public function onInit($param) { parent::onInit($param); @@ -28,41 +32,23 @@ class TForm extends TControl protected function addAttributesToRender($writer) { - $attributes=$this->getAttributes(); + $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); - $page=$this->getPage(); - /* - $onsubmit=$page->getClientOnSubmitEvent(); - if($onsubmit!=='') + if(($butt=$this->getDefaultButton())!=='') { - 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); + if(($button=$this->findControl($butt))!==null) + $this->getPage()->getClientScript()->registerDefaultButton($this,$button); else - throw new Exception('Only IButtonControl can be default button.'); - */ + throw new TInvalidDataValueException('form_defaultbutton_invalid',$butt); } - $writer->addAttribute('id',$this->getClientID()); - foreach($attributes as $name=>$value) - $writer->addAttribute($name,$value); } /** @@ -106,7 +92,7 @@ class TForm extends TControl public function setMethod($value) { - $this->setViewState('Method',$value,'post'); + $this->setViewState('Method',TPropertyValue::ensureEnum($value,'post','get'),'post'); } public function getEnctype() @@ -118,31 +104,11 @@ class TForm extends TControl { $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