Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

config_single_select()

Description

Generate an html single-select + options block

are used as the values of the options, and the values are the alternatives the user sees. (But
see $usekeys, below.) Usually a $lang entry whose value is an array of strings.
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.
Note: onChange event will call AutoSaveConfigOption([option name])

Parameters

ColumnTypeDefaultDescription
$name string The name of the select block. Usually the name of the config variable being set.
$label string The user text displayed to label the select block. Usually a $lang string.
$current string The current value of the config variable being set.
$choices
$usekeys boolean true Tells whether to use the keys from $choices as the values of the options. If set
$width integer 420 The width of the input field in pixels. Default: 420.
$title string null Title to be used for the label title. Default: null
$autosave boolean false Flag to say whether the there should be an auto save message feedback through JS. Default: false
$on_change_js null
$hidden false
array string $choices The array of the alternatives -- the options in the select block. The keys

Location

include/config_functions.php lines 767 to 804

Definition

 
function config_single_select($name$label$current$choices$usekeys true$width 420$title null$autosave false$on_change_js=null,$hidden=false)
{
    global 
$lang;
    
    if (
is_null($title)) {
        
// This is how it was used on plugins setup page. Makes sense for developers when trying to debug and not much for non-technical users
        
$title str_replace('%cvn'$name$lang['plugins-configvar']);
    }
    
?>

    <div class="Question" id="question_ echo escape($name); ?> if ($hidden){echo "style=\"display:none;\"";} ?>>
        <label for=" echo escape($name); ?>" title=" echo escape($title); ?>">
             echo strip_tags_and_attributes($label, ['a'], ['href''target']); ?>
        </label>
         if ($autosave) { ?>
            <div class="AutoSaveStatus">
                <span id="AutoSaveStatus- echo escape($name); ?>" style="display:none;"></span>
            </div>
         ?>
        <select id=" echo escape($name); ?>"
            name=" echo escape($name); ?>"
             if ($autosave) { ?>
                onChange=" echo $on_change_js?>AutoSaveConfigOption(' echo escape($name); ?>');"
             ?>
            style="width: echo (int) $width?>px">
             foreach ($choices as $key => $choice) {
                
$value $usekeys $key $choice?>
                <option value=" echo escape($value); ?>"
                     echo $current == $value ' selected' ''?>>
                     echo escape($choice); ?>
                </option>
             ?>
        </select>
        <div class="clearerleft"></div>
    </div>
    
    
}

This article was last updated 4th December 2024 09:05 Europe/London time based on the source file dated 13th November 2024 15:50 Europe/London time.