/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/form/form_elements/FEListBox.inc
ViewVC logotype

Annotation of /nfo/php/libs/com.newsblob.phphtmllib/form/form_elements/FEListBox.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Sat Feb 22 21:07:48 2003 UTC (21 years, 6 months ago) by jonen
Branch: MAIN
+ updated whole lib to version 2.2.1 (new FormProcessing since 2.2.0!)

1 jonen 1.1 <?php
2     /**
3     * This file contains the FEListBox, FEMultiListBox
4     *
5     * $Id: FEListBox.inc,v 1.4 2003/02/18 23:02:00 hemna Exp $
6     *
7     * @author Walter A. Boring IV <waboring@buildabetterweb.com>
8     * @author Suren Markosyan <suren@bcsweb.com>
9     * @package phpHtmlLib
10     * @subpackage FormProcessing
11     *
12     * @copyright LGPL - See LICENCE
13     *
14     */
15    
16     /**
17     * This is the ListBox FormElement which builds a
18     * select field with all of its options.
19     * It has no validation method.
20     *
21     *
22     * @author Walter A. Boring IV <waboring@buildabetterweb.com>
23     * @author Suren Markossian <suren@bcsweb.com>
24     * @package phpHtmlLib
25     * @subpackage FormProcessing
26     *
27     * @copyright LGPL - See LICENCE
28     */
29     class FEListBox extends FEDataList {
30    
31     /**
32     * This function builds and returns the
33     * form element object
34     *
35     * @return object
36     */
37     function get_element() {
38    
39     $attributes = $this->_build_element_attributes();
40    
41     if ($this->_height) {
42     $attributes["size"] = 5;
43     }
44    
45     $selected_value = $this->get_value();
46    
47     $tag = new SELECTtag($attributes);
48    
49     foreach ($this->_data_list as $name=>$value) {
50    
51     $attributes = array("value"=>$value);
52     if ($value == $selected_value) $attributes[] = "selected";
53    
54     $tag->add(new OPTIONtag($attributes, $name));
55     }
56     return $tag;
57     }
58     }
59    
60     /**
61     * This is the MultiListBox FormElement which builds a
62     * select field with all of its options. It enables
63     * the ability to have multiple selections.
64     * It has no validation method.
65     *
66     *
67     * @author Walter A. Boring IV <waboring@buildabetterweb.com>
68     * @author Suren Markossian <suren@bcsweb.com>
69     * @package phpHtmlLib
70     * @subpackage FormProcessing
71     *
72     * @copyright LGPL - See LICENCE
73     */
74     class FEMultiListBox extends FEListBox {
75    
76    
77     /**
78     * This function creates element name
79     * used in the form based on the text label
80     * or any other parameters
81     *
82     * Overriding things function to make sure
83     * an array is created instead of a single variable
84     */
85     function create_element_name() {
86    
87     parent::create_element_name();
88    
89     $this->_element_name .= "[]";
90     }
91    
92     /**
93     * This function builds and returns the
94     * form element object
95     *
96     * @return object
97     */
98     function get_element() {
99    
100     $attributes = $this->_build_element_attributes();
101    
102     $attributes[] = "multiple";
103    
104     if ($this->_height) {
105     $attributes["size"] = 5;
106     }
107    
108     $selected_values = $this->get_value();
109    
110     $tag = new SELECTtag($attributes);
111    
112     foreach ($this->_data_list as $name=>$value) {
113    
114     $attributes = array("value"=>$value);
115     if (is_array($selected_values) && in_array($value, $selected_values)) $attributes[] = "selected";
116    
117     $tag->add(new OPTIONtag($attributes, $name));
118     }
119     return $tag;
120     }
121     }
122     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed