You appear to be a bot. Output may be restricted
Description
Return a select list with the current selectionThe current value may either be a numeric index OR the actual string It's slightly more efficient when it's the index
Usage
$$iselect = iselect( $name, $value, $args );
Parameters
- $name
- ( string ) required – the name for the field
- $value
- ( string/mixed ) required – the key value for the current selection or an array for #multiple selection
- $args
- ( array ) required – containing "#options" which must point to a non empty array
Returns
$iselect HTML for the select listSource
File name: oik-bwtrace/libs/bobbforms.phpLines:
1 to 26 of 26
function iselect( $name, $value, $args ) { //bw_trace2(); $multiple = bw_array_get( $args, "#multiple", false ); if ( $multiple ) { $iselect = "<select name=\"${name}[]\" multiple size=\"$multiple\">" ; } else { $iselect = "<select name=\"$name\">" ; } $options = bw_as_array( $args['#options'] ); $optional = bw_array_get( $args, "#optional", false ); if ( $optional ) { $options = array( __( "None" ) ) + $options; } //bw_trace2( $options, "options" ); $bw_shorten = bw_query_shorten( $args ); foreach ( $options as $option_key => $option_value ) { $selected = is_selected( $option_key, $option_value, $value ); if ( $bw_shorten ) { $option_value = bw_shorten( $option_value, $bw_shorten ); } $option = "<option value=\"$option_key\" $selected>$option_value</option>"; $iselect .= $option; } $iselect .= "</select>" ; return( $iselect ); }View on GitHub View on Trac