summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Klaer <kj.landwehr.software@gmail.com>2015-08-18 15:17:42 +0200
committerJens Klaer <kj.landwehr.software@gmail.com>2015-08-18 15:17:42 +0200
commit4a4dd411abb23243d46a43e92deb4d22f2d34b17 (patch)
treedb744634d4ede351c84347313330d87c05ccbf49
parent72d9fc3857380744ab4996fd988532959a39e73d (diff)
TButton now supports using input or button for the tag name
the tag name used to render the TButton can now be changed by setting the property ButtonTag (defaults to input) using an enumerable class. this is especially useful when styling buttons using bootstrap along with prado.
-rw-r--r--framework/Web/UI/WebControls/TButton.php45
1 files changed, 42 insertions, 3 deletions
diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php
index f24985e6..d9383d1e 100644
--- a/framework/Web/UI/WebControls/TButton.php
+++ b/framework/Web/UI/WebControls/TButton.php
@@ -52,7 +52,23 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr
*/
protected function getTagName()
{
- return 'input';
+ return strtolower($this->getButtonTag());
+ }
+
+ /**
+ * @return TButtonTag the tag name of the button. Defaults to TButtonType::Input.
+ */
+ public function getButtonTag()
+ {
+ return $this->getViewState('ButtonTag',TButtonTag::Input);
+ }
+
+ /**
+ * @param TButtonTag the tag name of the button.
+ */
+ public function setButtonTag($value)
+ {
+ $this->setViewState('ButtonTag',TPropertyValue::ensureEnum($value,'TButtonTag'),TButtonTag::Input);
}
/**
@@ -83,7 +99,10 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr
$writer->addAttribute('type',strtolower($this->getButtonType()));
if(($uniqueID=$this->getUniqueID())!=='')
$writer->addAttribute('name',$uniqueID);
- $writer->addAttribute('value',$this->getText());
+ if($this->getButtonTag()===TButtonTag::Button)
+ $this->addParsedObject($this->getText());
+ else
+ $writer->addAttribute('value',$this->getText());
if($this->getEnabled(true))
{
if($this->getEnableClientScript() && $this->needPostBackScript())
@@ -171,11 +190,14 @@ class TButton extends TWebControl implements IPostBackEventHandler, IButtonContr
/**
* Renders the body content enclosed between the control tag.
- * This overrides the parent implementation with nothing to be rendered.
+ * This overrides the parent implementation with nothing to be rendered for input tags,
+ * button tags are rendered normally.
* @param THtmlWriter the writer used for the rendering purpose
*/
public function renderContents($writer)
{
+ if($this->getButtonTag()===TButtonTag::Button)
+ parent::renderContents($writer);
}
/**
@@ -363,3 +385,20 @@ class TButtonType extends TEnumerable
const Button='Button';
}
+/**
+ * TButtonTag class.
+ * TButtonTag defines the enumerable type for the possible tag names that a {@link TButton} can use for rendering.
+ *
+ * The following enumerable values are defined:
+ * - Input: an input tag is rendered
+ * - Button: a button tag is rendered
+ *
+ * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de>
+ * @package System.Web.UI.WebControls
+ */
+class TButtonTag extends TEnumerable
+{
+ const Input='Input';
+ const Button='Button';
+}
+