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

config_checkbox_select()

Description

Generate an html checkbox options block

used to generate the values of the checkbox, and the values are the checkbox labels the user sees. (But see
$usekeys, below.)
If set to false the values from $choices will be used for both the values of the options
and the text the user sees. Defaulted to true.

Parameters

ColumnTypeDefaultDescription
$name string the name of the checkbox block.
$label string the user text displayed to label the checkbox block. Usually a $lang string.
$current
$choices
$usekeys boolean true tells whether to use the keys from $choices as the values of the options.
$width integer 300 the width of the input field in pixels. Default: 300.
$columns integer 1 the number of columns to use
$autosave false
$on_change_js null
$hidden false
array string $choices the array of choices -- the list of checkboxes. The keys are

Location

include/config_functions.php lines 902 to 968

Definition

 
function config_checkbox_select($name$label$current$choices$usekeys=true$width=300$columns=1$autosave false,$on_change_js=null$hidden=false)
    {
    global 
$lang;
    if(
trim($current) != "")
        {
        
$currentvalues=explode(",",$current);
        }
    else
        {
        
$currentvalues = [];
        }
    
$wrap 0;
    
?>
    <div class="Question" id="question_ echo $name?> if ($hidden){echo "style=\"display:none;\"";} ?> >
    <label for=" echo escape($name)?>" > echo escape($label)?></label>
        
        
if($autosave)
            {
            
?>
            <div class="AutoSaveStatus">
                <span id="AutoSaveStatus- echo $name?>" style="display:none;"></span>
            </div>
            
            
}
        
?>
     
        <table cellpadding=2 cellspacing=0>
            <tr>
        
        
foreach($choices as $key => $choice)
            {
            
$value=$usekeys?$key:$choice;
            
$wrap++;
            if(
$wrap $columns)
                {
                
$wrap 1;
                
?>
                </tr>
                <tr>
                
                
}
                
?>
            <td width="1">
                <input type="checkbox"
                       name=" echo $name?>"
                       value=" echo $value?>"
                    
                    
if($autosave) { ?> onChange=" echo $on_change_js?>AutoSaveConfigOption(' echo $name?>');" }
                    if(
in_array($value$currentvalues))
                        {
                        
?>
                        checked
                        
                        
}?>
                    >
            </td>
            <td> echo escape(i18n_get_translated($choice)); ?>&nbsp;</td>
            
            
}
            
?>
            </tr>
        </table>
        <div class="clearerleft"></div>
  </div>
  

    
}

This article was last updated 19th March 2024 10:35 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.