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_integer_input()

Description

Generate an HTML form element for input of integer only values. Field will include validation for supplied value being of type
int and between supplied min and max values.
While this function can handle client side validation, config_check_valid_option() must be used on save to allow for server
side checking of the value. For an example, see pages/admin/admin_system_config.php

Parameters

ColumnTypeDefaultDescription
$name string The name of the configuration variable to be added.
$label string The user text displayed to label the text block. Usually a $lang string.
$current string The current value of the config variable being set.
$min_value int Minimum value permitted in field.
$max_value int Maximum value permitted in field.
$width int 55 The width of the input field in pixels. Default: 55.
$title string null The title attribute of the element
$autosave bool false Enable auto-saving of changes when focus is lost
$hidden bool false Whether field is hidden on the page
$help_link string "": void { global $lang; if is_null$title Help link to be displayed alongside the label.

Return

void

Location

include/config_functions.php lines 673 to 730

Definition

 
function config_integer_input($name$label$current$min_value$max_value$width 55$title null$autosave false$hidden false$help_link ""): void
{
    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); ?> echo $hidden 'style="display:none;"' ''?>>
        <label for=" echo escape($name); ?>" title=" echo escape($title); ?>">
            
            
echo strip_tags_and_attributes($label, ['a'], ['href''target']);
            if (
$help_link !== "") {
                
render_help_link($help_link);
            }
            
?>
        </label>
        
        
if ($autosave) {
            
?>
            <div class="AutoSaveStatus">
                <span id="AutoSaveStatus- echo escape($name); ?>" style="display:none;"></span>
            </div>
            
        
}
            
?>
            <input type="text" id=" echo escape($name); ?>"
                inputmode="numeric"
                pattern="[0-9]*"
                name=" echo escape($name); ?>"
                value=" echo escape((string) $current); ?>"
                 if ($autosave) { ?>
                    onchange="if (isValidInt echo escape($name); ?>(this.value)) {AutoSaveConfigOption(' echo escape($name); ?>');}"
                 ?>
                style="width: echo (int) $width?>px"
            />
            <script>
                 echo escape($name); ?>.addEventListener('input', () => {
                     echo escape($name); ?>.value =  echo escape($name); ?>.value.replace(/\D/g, '');
                });
            function isValidInt echo escape($name); ?>(fieldValue)
            {
                const inputVal = Number(fieldValue.trim());
                if (!Number.isInteger(inputVal) || inputVal <  echo escape($min_value); ?> || inputVal >  echo escape($max_value); ?>) {
                    styledalert(' echo escape($lang["error"]) ?>', ' echo escape(str_replace(array('%MIN%''%MAX%'), array($min_value$max_value), $lang['config_integer_invalid_range'])); ?>');
                    return false;
                } else {
                    return true;
                }
            }
            </script>
        <div class="clearerleft"></div>
    </div>

    
}

This article was last updated 19th February 2026 11:35 Europe/London time based on the source file dated 19th February 2026 08:55 Europe/London time.