Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

render_select_option()

Parameters

ColumnTypeDefaultDescription
$fieldname
$opt_array
$selected
$groupby ''

Location

include/config_functions.php lines 31 to 53

Definition

 
function render_select_option($fieldname$opt_array$selected$groupby=''){
    global 
$errorfields$lang;
    
$output '';
    
$output .= "<tr><th><label for=\"$fieldname\">".$lang['cfg-'.$fieldname]."</label></th>";
    
$output .= "<td><select name=\"$fieldname\">";
    if (
$groupby!=''){
        
$cur_group $opt_array[0][$groupby];
        
$output .= "<optgroup label=\"$cur_group\">";
    }
    foreach (
$opt_array as $option){
        if (
$groupby!='' && $cur_group!=$option[$groupby]){
          
$cur_group $option[$groupby];
          
$output .= "</optgroup><optgroup label=\"$cur_group\">";            
        }
        
$output .= "<option ";
        
$output .= $option['value']==$selected?'selected="selected" ':'';
        
$output .= "value=\"{$option['value']}\">{$option['label']}</option>";
    }
    
$output .= '</optgroup>';
    
$output .= isset($errorfields[$fieldname])?'<span class="error">* '.$errorfields[$fieldname].'</span>':'';
    
$output .= '</td></tr>';
    return 
$output;
}

This article was last updated 21st May 2024 11:05 Europe/London time based on the source file dated 14th May 2024 18:25 Europe/London time.