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

config_boolean_select()

Description

Generate an html boolean select block

to array('False', 'True') in the local language.
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 boolean The current value (true or false) of the config variable being set.
$choices ''
$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
$help string '' Help text to display for this question
$reload_page boolean false Reload the page after saving, useful for large CSS changes.
array string $choices Array of the text to display for the two choices: False and True. Defaults

Location

include/config_functions.php lines 805 to 867

Definition

 
function config_boolean_select(
    
$name,
    
$label,
    
$current,
    
$choices '',
    
$width 420,
    
$title null,
    
$autosave false,
    
$on_change_js null,
    
$hidden false,
    
string $help '',
    
bool $reload_page false
)
    {
    global 
$lang;

    
$help trim($help);

    if(
$choices == '')
        {
        
$choices $lang['false-true'];
        }

    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']);
        }
    
    
$html_question_id "question_{$name}";
    
?>
    <div class="Question" id=" echo escape($html_question_id); ?> if ($hidden){echo "style=\"display:none;\"";} ?> >
        <label for=" echo $name?>" title=" echo $title?>"> echo $label?></label>

        
        
if($autosave)
            {
            
?>
            <div class="AutoSaveStatus">
                <span id="AutoSaveStatus- echo $name?>" style="display:none;"></span>
            </div>
            
            
}
            
?>
        <select id=" echo $name?>"
                name=" echo $name?>"
                 if($autosave) { ?>
                    onChange=" echo $on_change_js?>AutoSaveConfigOption(' echo escape($name); ?>' echo $reload_page ", true" ""?>);"
                 ?>
                style="width: echo $width?>px">
            <option value="1" if($current == '1') { ?> selected ?>> echo $choices[1]; ?></option>
            <option value="0" if($current == '0') { ?> selected ?>> echo $choices[0]; ?></option>
        </select>
        
        
if ($help !== '')
            {
            
render_question_form_helper($help$html_question_id, []);
            }
        
?>
        <div class="clearerleft"></div>
    </div>
    
    
}

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