diff options
author | xue <> | 2006-02-19 05:10:07 +0000 |
---|---|---|
committer | xue <> | 2006-02-19 05:10:07 +0000 |
commit | fb2ba05edf43665152150f65731a80ecb327b5da (patch) | |
tree | e38fa214f90d86e7be05bd31d16739a87fd0666f /framework/Web/UI/TForm.php | |
parent | d38334fc8aac7b4488a6fa10fe6acc219665c3bd (diff) |
Made TForm DefaultButton working.
Diffstat (limited to 'framework/Web/UI/TForm.php')
-rw-r--r-- | framework/Web/UI/TForm.php | 60 |
1 files changed, 13 insertions, 47 deletions
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 |