summaryrefslogtreecommitdiff
path: root/framework/Web/UI
diff options
context:
space:
mode:
authorxue <>2006-02-19 05:10:07 +0000
committerxue <>2006-02-19 05:10:07 +0000
commitfb2ba05edf43665152150f65731a80ecb327b5da (patch)
treee38fa214f90d86e7be05bd31d16739a87fd0666f /framework/Web/UI
parentd38334fc8aac7b4488a6fa10fe6acc219665c3bd (diff)
Made TForm DefaultButton working.
Diffstat (limited to 'framework/Web/UI')
-rw-r--r--framework/Web/UI/TClientScriptManager.php1
-rw-r--r--framework/Web/UI/TForm.php60
-rw-r--r--framework/Web/UI/TPage.php42
3 files changed, 14 insertions, 89 deletions
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php
index 381ee82b..180106ce 100644
--- a/framework/Web/UI/TClientScriptManager.php
+++ b/framework/Web/UI/TClientScriptManager.php
@@ -171,6 +171,7 @@ class TClientScriptManager extends TApplicationComponent
$options = TJavaScript::encode($this->getDefaultButtonOptions($panel, $button));
$code = "new Prado.WebUI.DefaultButton($options);";
$this->registerEndScript("prado:".$panel->getClientID(), $code);
+ $this->registerPradoScript('prado');
}
/**
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
diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php
index 6e83e3be..88606250 100644
--- a/framework/Web/UI/TPage.php
+++ b/framework/Web/UI/TPage.php
@@ -18,8 +18,6 @@ Prado::using('System.Web.UI.TTemplateControl');
Prado::using('System.Web.UI.TForm');
Prado::using('System.Web.UI.TClientScriptManager');
-//Prado::using('System.Web
-
/**
* TPage class
*
@@ -210,46 +208,6 @@ class TPage extends TTemplateControl
}
/**
- * Loads and parses the page template.
- * This method overrides the parent implementation by allowing loading
- * a page template from a specified template file.
- * @return ITemplate the parsed template structure
- */
- protected function loadTemplate()
- {
- if($this->_templateFile===null)
- return parent::loadTemplate();
- else
- {
- $template=$this->getService()->getTemplateManager()->getTemplateByFileName($this->_templateFile);
- $this->setTemplate($template);
- return $template;
- }
- }
-
- /**
- * @return string the user-specified template file, defaults to null.
- */
- public function getTemplateFile()
- {
- return $this->_templateFile;
- }
-
- /**
- * Sets the user-specified template file.
- * The template file must be specified in a namespace format.
- * @param string the user-specified template file.
- * @throws TInvalidDataValueException if the file is not in namespace format.
- */
- public function setTemplateFile($value)
- {
- if(($templateFile=Prado::getPathOfNamespace($value,TTemplateManager::TEMPLATE_FILE_EXT))===null || !is_file($templateFile))
- throw new TInvalidDataValueException('page_templatefile_invalid',$value);
- else
- $this->_templateFile=$templateFile;
- }
-
- /**
* Registers a TForm instance to the page.
* Note, a page can contain at most one TForm instance.
* @param TForm the form on the page