select options, generated dropdown combobox options control select dynamic database sql query tree hierarchy select

select

A single select like this:

or a multiple select like this (use the mouse button to select a range by dragging, or use the Control key while clicking on some values to select/deselect values that are not in a range):

single select

<?php
$config 
= Array(
  
'id' => Array(
    
'type'           => 'select',
    
'displayname'    => 'This is a static select',
    
'values'         => 
      Array( 
        
=> 'choose nothing'
        
=> 'value 1'
        
=> 'value 2'
      
),
    
'value'          => '0',
    
'html'           => 'class="inputfieldstyle"',
    
'help'           => 'validation failed for this element',
    
'rowlayout'      => '...%element% %prefix% %postfix% etc...',
    
'prefix'         => 'string to display before element',
    
'postfix'        => 'string to display after element',
    
'readonly'       => 0,
    
'display'        => 0,
    
'htmlid'         => 'name1',
  )
);
?>

multiple select

IMPORTANT: always use multiple="multiple" in the 'html' parameter and [] in the field name.

<?php
$config 
= Array(

  
'id[]' => Array(
    
'type'           => 'select',
    
'displayname'    => 'This is a static multiple select',
    
'values'         => 
      Array( 
        
=> 'choose nothing'
        
=> 'value 1'
        
=> 'value 2'
      
),
    
'value'     => '0' | Array( 1,),
    
'html'      => 'multiple="multiple"'// an XHTML compatible way of the multiple parameter
    
'help'      => 'validation failed for this element',
    
'rowlayout=> '...%element% %prefix% %postfix% etc...',
    
'prefix'    => 'string to display before element',
    
'postfix'   => 'string to display after element',
    
'readonly'  => 0,
    
'display'   => 0,
    
'htmlid'    => 'name1',
  )
);
?>

Live examples:

Validators to use together with this element:

form validation for developers!

clonefish is a proven, mature form generator class that helps PHP developers to create, validate and process secure, flexible and easy-to-maintain forms
learn more
Bookmark and Share