[Phphtmllib-devel] SF.net SVN: phphtmllib: [2871] trunk/phphtmllib/src/form/form_elements/ FETextAr
Status: Beta
Brought to you by:
hemna
From: <su...@us...> - 2007-08-27 19:33:18
|
Revision: 2871 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=2871&view=rev Author: suren2 Date: 2007-08-27 12:33:14 -0700 (Mon, 27 Aug 2007) Log Message: ----------- add support for desc text Modified Paths: -------------- trunk/phphtmllib/src/form/form_elements/FETextArea.inc Modified: trunk/phphtmllib/src/form/form_elements/FETextArea.inc =================================================================== --- trunk/phphtmllib/src/form/form_elements/FETextArea.inc 2007-08-24 04:22:18 UTC (rev 2870) +++ trunk/phphtmllib/src/form/form_elements/FETextArea.inc 2007-08-27 19:33:14 UTC (rev 2871) @@ -16,6 +16,18 @@ class FETextArea extends FEBoxElement { /** + * Holds text that is displayed inside + * the text box and goes away when + * user clicks on it + * + * Most useful in the form of + * "enter your name here" + * + * @var string + */ + protected $value_description; + + /** * This lets you limit the amount of data to * accept in the field */ @@ -51,18 +63,41 @@ */ public function get_element() { + $value = $this->get_value(); $attributes = $this->build_element_attributes(); + if (!$value && $this->value_description) { + $attributes['onFocus'] = "if (this.innerHTML == '$this->value_description') {this.innerHTML='';}"; + $attributes['onBlur'] = "if (this.innerHTML == '') {this.innerHTML='$this->value_description';}"; + } + $tag = new TEXTAREAtag($attributes); - if (($value = $this->get_value()) != NULL) { + if ($value) { $tag->add($value); } + if ($this->value_description) { + $tag->add($this->value_description); + } return $tag; } /** + * Sets text that is displayed inside + * the text box and goes away when + * user clicks on it + * + * Most useful in the form of + * "enter your name here" + * + * @var string $text + */ + public function set_value_description($text) { + $this->value_description = $text; + } + + /** * This method validates the data * for this Form Element. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |