2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
3 // +----------------------------------------------------------------------+
5 // +----------------------------------------------------------------------+
6 // | Copyright (c) 1997-2003 The PHP Group |
7 // +----------------------------------------------------------------------+
8 // | This source file is subject to version 2.0 of the PHP license, |
9 // | that is bundled with this package in the file LICENSE, and is |
10 // | available at through the world-wide-web at |
11 // | http://www.php.net/license/2_02.txt. |
12 // | If you did not receive a copy of the PHP license and are unable to |
13 // | obtain it through the world-wide-web, please send a note to |
14 // | license@php.net so we can mail you a copy immediately. |
15 // +----------------------------------------------------------------------+
16 // | Authors: Adam Daniel <adaniel1@eesus.jnj.com> |
17 // | Bertrand Mansion <bmansion@mamasam.com> |
18 // +----------------------------------------------------------------------+
22 require_once("HTML/QuickForm/element.php");
25 * HTML class for static data
27 * @author Wojciech Gdela <eltehaem@poczta.onet.pl>
30 class HTML_QuickForm_static
extends HTML_QuickForm_element
{
47 * @param string $elementLabel (optional)Label
48 * @param string $text (optional)Display text
52 function HTML_QuickForm_static($elementName=null, $elementLabel=null, $text=null)
54 HTML_QuickForm_element
::HTML_QuickForm_element($elementName, $elementLabel);
55 $this->_persistantFreeze
= false;
56 $this->_type
= 'static';
64 * Sets the element name
66 * @param string $name Element name
70 function setName($name)
72 $this->updateAttributes(array('name'=>$name));
79 * Returns the element name
86 return $this->getAttribute('name');
99 function setText($text)
101 $this->_text
= $text;
102 } // end func setText
108 * Sets the text (uses the standard setValue call to emulate a form element.
110 * @param string $text
114 function setValue($text)
116 $this->setText($text);
117 } // end func setValue
123 * Returns the static text element in HTML
130 return $this->_getTabs() . $this->_text
;
134 // {{{ getFrozenHtml()
137 * Returns the value of field without HTML tags
142 function getFrozenHtml()
144 return $this->toHtml();
145 } //end func getFrozenHtml
148 // {{{ onQuickFormEvent()
151 * Called by HTML_QuickForm whenever form event is made on this element
153 * @param string $event Name of event
154 * @param mixed $arg event arguments
155 * @param object $caller calling object
161 function onQuickFormEvent($event, $arg, &$caller)
165 // do NOT use submitted values for static elements
166 $value = $this->_findValue($caller->_constantValues
);
167 if (null === $value) {
168 $value = $this->_findValue($caller->_defaultValues
);
170 if (null !== $value) {
171 $this->setValue($value);
175 parent
::onQuickFormEvent($event, $arg, $caller);
178 } // end func onQuickFormEvent
184 * We override this here because we don't want any values from static elements
186 function exportValue(&$submitValues, $assoc = false)
192 } //end class HTML_QuickForm_static