Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / httemplate / elements / select.html
index 67ef514..100df94 100644 (file)
@@ -1,13 +1,43 @@
+<%doc>
+<& select.html,
+  # required
+    field       => 'myfield', # NAME property
+    curr_value  => 'foo',
+    labels      => { # or 'option_labels'
+                     # note: these will be escaped for you, don't escape them
+                     'AL' => 'Alabama',
+                     'AK' => 'Alaska',
+                     'AR' => 'Arkansas',
+                   },
+    options     => [ 'AL', 'AK', 'AR' ],
+    curr_value  => scalar( $cgi->param('myfield') ),
+
+  # recommended    
+    id          => 'myid',    # DOM id
+
+  # optional
+    size        => 1,         # to show multiple rows at once
+    style       => '',        # STYLE property
+    multiple    => 0,
+    disabled    => 0,
+    onchange    => 'do_something()',
+    js_only     => 0,         # disables the whole thing
+    element_etc => '',        # anything else to put in the <select> tag
+&>
+</%doc>
+    
 % unless ( $opt{'js_only'} ) {
 
 <SELECT NAME          = "<% $opt{field} %>"
         ID            = "<% $opt{id} %>"
         previousValue = "<% $curr_value %>"
-        previousText  = "<% $labels->{$curr_value} || $curr_value %>"
+        previousText  = "<% $labels->{$curr_value} || $curr_value |h %>"
+        <% $multiple %>
         <% $size %>
         <% $style %>
         <% $opt{disabled} %>
         <% $onchange %>
+        <% $opt{'element_etc'} %>
 >
 
 % if ( $opt{options} ) {
@@ -17,7 +47,7 @@
       <OPTION VALUE="<% $option %>"
               <% $opt{curr_value} eq $option ? 'SELECTED' : '' %>
       >
-        <% $labels->{$option} || $option %>
+        <% $labels->{$option} || $option |h %>
       </OPTION>
 
 %   }
@@ -39,7 +69,7 @@
 %
 % }
 
-</SELECT>
+</SELECT> <% $opt{'post_field_label'} %>
 
 % }
 <%init>
@@ -74,4 +104,6 @@ my $style = scalar(@style) ? 'STYLE="'. join(';', @style). '"' : '';
 
 my $size = $opt{'size'} ? 'SIZE='.$opt{'size'} : '';
 
+my $multiple = $opt{'multiple'} ? 'MULTIPLE' : '';
+
 </%init>