320 |
jpm |
1 |
<?php
|
|
|
2 |
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +----------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.0 |
|
|
|
5 |
// +----------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (c) 1997, 1998, 1999, 2000, 2001 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 |
// +----------------------------------------------------------------------+
|
|
|
19 |
//
|
443 |
ddelon |
20 |
// $Id: hiddenselect.php,v 1.2 2005-09-20 17:01:22 ddelon Exp $
|
320 |
jpm |
21 |
|
|
|
22 |
require_once('HTML/QuickForm/select.php');
|
|
|
23 |
|
|
|
24 |
/**
|
|
|
25 |
* This class takes the same arguments as a select element, but instead
|
|
|
26 |
* of creating a select ring it creates hidden elements for all values
|
|
|
27 |
* already selected with setDefault or setConstant. This is useful if
|
|
|
28 |
* you have a select ring that you don't want visible, but you need all
|
|
|
29 |
* selected values to be passed.
|
|
|
30 |
*
|
|
|
31 |
* @author Isaac Shepard <ishepard@bsiweb.com>
|
|
|
32 |
*
|
|
|
33 |
* @version 1.0
|
|
|
34 |
* @since 2.1
|
|
|
35 |
* @access public
|
|
|
36 |
*/
|
|
|
37 |
class HTML_QuickForm_hiddenselect extends HTML_QuickForm_select
|
|
|
38 |
{
|
|
|
39 |
// {{{ constructor
|
|
|
40 |
|
|
|
41 |
/**
|
|
|
42 |
* Class constructor
|
|
|
43 |
*
|
|
|
44 |
* @param string Select name attribute
|
|
|
45 |
* @param mixed Label(s) for the select (not used)
|
|
|
46 |
* @param mixed Data to be used to populate options
|
|
|
47 |
* @param mixed Either a typical HTML attribute string or an associative array (not used)
|
|
|
48 |
* @since 1.0
|
|
|
49 |
* @access public
|
|
|
50 |
* @return void
|
|
|
51 |
*/
|
|
|
52 |
function HTML_QuickForm_hiddenselect($elementName=null, $elementLabel=null, $options=null, $attributes=null)
|
|
|
53 |
{
|
|
|
54 |
HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
|
|
|
55 |
$this->_persistantFreeze = true;
|
|
|
56 |
$this->_type = 'hiddenselect';
|
|
|
57 |
if (isset($options)) {
|
|
|
58 |
$this->load($options);
|
|
|
59 |
}
|
|
|
60 |
} //end constructor
|
|
|
61 |
|
|
|
62 |
// }}}
|
|
|
63 |
// {{{ toHtml()
|
|
|
64 |
|
|
|
65 |
/**
|
|
|
66 |
* Returns the SELECT in HTML
|
|
|
67 |
*
|
|
|
68 |
* @since 1.0
|
|
|
69 |
* @access public
|
|
|
70 |
* @return string
|
|
|
71 |
* @throws
|
|
|
72 |
*/
|
|
|
73 |
function toHtml()
|
|
|
74 |
{
|
|
|
75 |
$tabs = $this->_getTabs();
|
|
|
76 |
$name = $this->getPrivateName();
|
|
|
77 |
$strHtml = '';
|
|
|
78 |
|
|
|
79 |
foreach ($this->_values as $key => $val) {
|
|
|
80 |
for ($i = 0, $optCount = count($this->_options); $i < $optCount; $i++) {
|
|
|
81 |
if ($val == $this->_options[$i]['attr']['value']) {
|
443 |
ddelon |
82 |
$strHtml .= $tabs . '<input' . $this->_getAttrString(array(
|
|
|
83 |
'type' => 'hidden',
|
|
|
84 |
'name' => $name,
|
|
|
85 |
'value' => $val
|
|
|
86 |
)) . " />\n" ;
|
320 |
jpm |
87 |
}
|
|
|
88 |
}
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
return $strHtml;
|
|
|
92 |
} //end func toHtml
|
|
|
93 |
|
|
|
94 |
// }}}
|
|
|
95 |
// {{{ accept()
|
|
|
96 |
|
|
|
97 |
/**
|
|
|
98 |
* This is essentially a hidden element and should be rendered as one
|
|
|
99 |
*/
|
|
|
100 |
function accept(&$renderer)
|
|
|
101 |
{
|
|
|
102 |
$renderer->renderHidden($this);
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
// }}}
|
|
|
106 |
} //end class HTML_QuickForm_hiddenselect
|
|
|
107 |
?>
|