diff options
Diffstat (limited to 'framework')
-rw-r--r-- | framework/Web/UI/TClientScriptManager.php | 14 | ||||
-rw-r--r-- | framework/Web/UI/TPage.php | 4 |
2 files changed, 14 insertions, 4 deletions
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index 27029f56..cc5289c5 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -280,7 +280,9 @@ class TClientScriptManager extends TComponent public function registerHiddenField($name,$value)
{
- $this->_hiddenFields[$name]=$value;
+ // if the named hidden field exists and has a value null, it means the hidden field is rendered already
+ if(!isset($this->_hiddenFields[$name]) || $this->_hiddenFields[$name]!==null)
+ $this->_hiddenFields[$name]=$value;
}
public function registerOnSubmitStatement($key,$script)
@@ -365,8 +367,14 @@ class TClientScriptManager extends TComponent $str='';
foreach($this->_hiddenFields as $name=>$value)
{
- $value=THttpUtility::htmlEncode($value);
- $str.="<input type=\"hidden\" name=\"$name\" id=\"$name\" value=\"$value\" />\n";
+ if($value!==null)
+ {
+ $value=THttpUtility::htmlEncode($value);
+ $str.="<input type=\"hidden\" name=\"$name\" id=\"$name\" value=\"$value\" />\n";
+ // set hidden field value to null to indicate this field is rendered
+ // Note, hidden field rendering is invoked twice (at the beginning and ending of TForm)
+ $this->_hiddenFields[$name]=null;
+ }
}
if($str!=='')
$writer->write("<div>\n".$str."</div>\n");
diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php index 2985e4d6..8d2c9686 100644 --- a/framework/Web/UI/TPage.php +++ b/framework/Web/UI/TPage.php @@ -694,7 +694,9 @@ class TPage extends TTemplateControl throw new TInvalidConfigurationException('page_singleform_required');
$this->_formRendered=true;
$this->_inFormRender=true;
- $this->getClientScript()->renderBeginScripts($writer);
+ $cs=$this->getClientScript();
+ $cs->renderHiddenFields($writer);
+ $cs->renderBeginScripts($writer);
}
/**
|