======================== CODE SNIPPETS ======================== TITLE: Display Warning with tmpl_if (HTML) DESCRIPTION: Demonstrates how to use the tag with a comparison operator (>) to display a warning message if a template variable (disk_usage) exceeds another (disk_quota). SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_16 LANGUAGE: html CODE: ```
Disk quota exceeded!
``` ---------------------------------------- TITLE: Include Static File - ISPConfig Template - HTML DESCRIPTION: Includes the content of another template file statically at the point of the tag. Useful for reusing common parts like headers or footers. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_10 LANGUAGE: HTML CODE: ``` ``` ---------------------------------------- TITLE: Include Dynamic File - ISPConfig Template - HTML DESCRIPTION: Includes the content of a template file whose name is determined by the value of a template variable. Allows for dynamic content loading based on context. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_11 LANGUAGE: HTML CODE: ``` ``` ---------------------------------------- TITLE: Output Variable Value - ISPConfig Template - HTML DESCRIPTION: Outputs the raw value of the specified template variable directly into the HTML output. Basic way to display dynamic data. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_5 LANGUAGE: HTML CODE: ``` {tmpl_var name='username'} ``` ---------------------------------------- TITLE: Dynamic Include and Loop Context in Template (HTML) DESCRIPTION: Demonstrates how to use to include a template file dynamically based on a variable set in PHP and how to use the __FIRST__ loop context variable within a . SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_20 LANGUAGE: html CODE: ``` {tmpl_var name='username'} First ``` ---------------------------------------- TITLE: List Items with tmpl_loop and Empty State (HTML) DESCRIPTION: Shows how to use to check if a list of items exists and then use to iterate over the items. Includes an block to display a message when the list is empty. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_17 LANGUAGE: html CODE: ```
  • {tmpl_var name='item_label'}
No items found.
``` ---------------------------------------- TITLE: Rendering TEXT Field in ISPConfig Template (HTML) DESCRIPTION: HTML template example for rendering a single-line text input field using ISPConfig template variables. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-types.md#_snippet_8 LANGUAGE: HTML CODE: ```
``` ---------------------------------------- TITLE: Rendering PASSWORD Field in ISPConfig Template (HTML) DESCRIPTION: HTML template example for rendering a password input field using ISPConfig template variables. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-types.md#_snippet_9 LANGUAGE: HTML CODE: ```
``` ---------------------------------------- TITLE: Show/Hide Form Field Conditionally - ISPConfig Template - HTML DESCRIPTION: A practical example demonstrating how to use to conditionally display an entire form group (label and input/value) based on a variable, such as user permissions. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_15 LANGUAGE: HTML CODE: ```
{tmpl_var name='quota'}
``` ---------------------------------------- TITLE: Conditionally Render Content (Unless) - ISPConfig Template - HTML DESCRIPTION: Renders the enclosed content only if the specified variable is not set or evaluates to false. The inverse of . SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_2 LANGUAGE: HTML CODE: ```
No domains configured yet.
``` ---------------------------------------- TITLE: Compare Variable Value - ISPConfig Template - HTML DESCRIPTION: Compares a variable's value against a specified literal value using various operators (==, !=, >, <, >=, <=). Renders content based on the comparison result. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_3 LANGUAGE: HTML CODE: ``` Active Inactive ``` ---------------------------------------- TITLE: Loop with Context Variables - ISPConfig Template - HTML DESCRIPTION: Demonstrates using special variables within a (like __FIRST__, __LAST__, __EVEN__, __ODD__, __ROWNUM__) to apply specific logic or display information based on the current iteration's position or properties. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_9 LANGUAGE: HTML CODE: ``` {tmpl_var name='username'} First user Last user Even row Odd row Row: {tmpl_var name='__ROWNUM__'} ``` ---------------------------------------- TITLE: Rendering CHECKBOX Field in ISPConfig Template (HTML) DESCRIPTION: HTML template example for rendering a single checkbox field using ISPConfig template variables. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-types.md#_snippet_12 LANGUAGE: HTML CODE: ```
{tmpl_var name='active'}
``` ---------------------------------------- TITLE: Conditional Logic with Else - ISPConfig Template - HTML DESCRIPTION: Provides an alternative content block to render when the condition evaluates to false. Allows for displaying different content based on a boolean variable. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_1 LANGUAGE: HTML CODE: ```
Welcome, admin!
Welcome, user!
``` ---------------------------------------- TITLE: Iterate Over Array - ISPConfig Template - HTML DESCRIPTION: Loops through each item in an array variable, rendering the enclosed content block for every item. Variables within the loop context refer to the current item's properties. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_4 LANGUAGE: HTML CODE: ``` {tmpl_var name='domain'} {tmpl_var name='status'} ``` ---------------------------------------- TITLE: Include PHP File (Conditional) - ISPConfig Template - HTML DESCRIPTION: Directly includes and executes a PHP file at this point in the template rendering process. *Requires the ENABLE_PHPINCLUDE option to be enabled.* Use with caution. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_14 LANGUAGE: HTML CODE: ``` ``` ---------------------------------------- TITLE: Multi-condition Logic (Elseif) - ISPConfig Template - HTML DESCRIPTION: Extends with to handle multiple possible conditions sequentially. Renders the first block whose condition evaluates to true, falling back to if none match. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_8 LANGUAGE: HTML CODE: ``` Active Pending Inactive ``` ---------------------------------------- TITLE: Rendering SELECT Field in ISPConfig Template (HTML) DESCRIPTION: HTML template example for rendering a dropdown select field using ISPConfig template variables, showing where options are injected. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-types.md#_snippet_10 LANGUAGE: HTML CODE: ```
``` ---------------------------------------- TITLE: Conditionally Render Content - ISPConfig Template - HTML DESCRIPTION: Renders the enclosed content only if the specified variable is set and evaluates to true. Useful for showing elements based on user permissions or data availability. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_0 LANGUAGE: HTML CODE: ```
You are an admin.
``` ---------------------------------------- TITLE: Output Variable with Formatting/Escaping - ISPConfig Template - HTML DESCRIPTION: Outputs a variable's value after applying specified formatting functions (e.g., strtoupper, ucfirst) and escaping (e.g., html, url) for safe display. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_7 LANGUAGE: HTML CODE: ``` {tmpl_var name='domain' format='strtoupper' escape='html'} ``` ---------------------------------------- TITLE: Template Comment Block - ISPConfig Template - HTML DESCRIPTION: Defines a block of text that is ignored by the template engine and does not appear in the final output. Used for adding notes or temporarily disabling template code. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_12 LANGUAGE: HTML CODE: ``` This section is for developers only and will not appear in output. ``` ---------------------------------------- TITLE: Nested Logic and Iteration - ISPConfig Template - HTML DESCRIPTION: Demonstrates combining and tags. Loops through a list of users and conditionally displays "Admin" or "User" based on a property of the current user object within the loop. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_6 LANGUAGE: HTML CODE: ``` {tmpl_var name='username'} Admin User ``` ---------------------------------------- TITLE: Rendering MULTIPLE Field in ISPConfig Template (HTML) DESCRIPTION: HTML template example for rendering a multi-select dropdown field using ISPConfig template variables, indicating where options are injected. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-types.md#_snippet_11 LANGUAGE: HTML CODE: ```
``` ---------------------------------------- TITLE: Trigger PHP Hook - ISPConfig Template - HTML DESCRIPTION: Inserts a marker in the template that triggers a corresponding PHP hook function defined in the ISPConfig backend. Allows for extending template rendering logic from PHP modules. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_13 LANGUAGE: HTML CODE: ``` ``` ---------------------------------------- TITLE: Rendering CHECKBOXARRAY Field in ISPConfig Template (HTML) DESCRIPTION: HTML template example for rendering a group of checkboxes (checkbox array) using ISPConfig template variables. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-types.md#_snippet_13 LANGUAGE: HTML CODE: ```
{tmpl_var name='features'}
``` ---------------------------------------- TITLE: Assign Variables and Loops in PHP DESCRIPTION: Shows how to use the $tpl->setInclude() method to assign a template file name to a variable for dynamic inclusion and $tpl->setLoop() to assign a PHP array to a template loop variable. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_19 LANGUAGE: php CODE: ``` // PHP $tpl->setInclude('content_tpl', 'form_content.htm'); $tpl->setLoop('users', $usersArray); ``` ---------------------------------------- TITLE: Use tmpl_unless for Negative Condition (HTML) DESCRIPTION: Illustrates the use of the tag as an alternative to or similar, to display content only when a variable is false or not set. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/template-logic.md#_snippet_18 LANGUAGE: html CODE: ```
SSL is not enabled for this domain.
``` ---------------------------------------- TITLE: Defining Top-Level Form Properties in PHP DESCRIPTION: This snippet illustrates how core form properties are set in an ISPConfig .tform.php file. It shows assignments for the form's title, description, unique name, associated database table and primary key, action script, history setting, default tab and list pages, and authentication requirements. It also includes an example of setting default permission presets for new records. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-file-structure.md#_snippet_0 LANGUAGE: php CODE: ``` $form["title"] = "My Module"; // Form title $form["description"] = "..."; // Form description $form["name"] = "module_name"; // Unique form identifier $form["record_name_field"] = "name"; // Field for record display $form["action"] = "module_edit.php"; // Submit handler script $form["db_table"] = "module_table"; // Database table $form["db_table_idx"] = "id"; // Primary key column $form["db_history"] = "yes"; // Enable history (yes/no) $form["tab_default"] = "main"; // Default tab $form["list_default"] = "module_list.php"; // Default list page $form["auth"] = "yes"; // Enable auth check (yes/no) // Permission presets when creating new records (record_id = 0) $form["auth_preset"]["userid"] = 0; $form["auth_preset"]["groupid"] = 0; $form["auth_preset"]["perm_user"] = 'riud'; $form["auth_preset"]["perm_group"] = 'riud'; $form["auth_preset"]["perm_other"] = ''; ``` ---------------------------------------- TITLE: ISPConfig Server Backend Directory Structure (Bash) DESCRIPTION: This snippet shows the directory layout for the ISPConfig server backend, located at /usr/local/ispconfig/server/. It includes directories for CLI tools, configuration templates, libraries, modules, plugins, scripts, and temporary files. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/folder-structure.md#_snippet_0 LANGUAGE: bash CODE: ``` server/ ├── aps_packages/ # APS packaging resources and definitions (deprecated) ├── cli/ # Command-line interface tools │ ├── ispc # CLI shell script wrapper │ ├── ispc.php # Main PHP CLI entry point │ └── modules/ # CLI modules │ ├── extension.inc.php # ISPConfig extension management │ ├── help.inc.php # CLI help generator │ ├── letsencrypt.inc.php # Let's Encrypt integration │ ├── php.inc.php # PHP module helper │ ├── update.inc.php # Update management │ ├── user.inc.php # User management │ └── version.inc.php # Version info ├── conf/ # Default configuration templates ├── conf-custom/ # Custom configuration overrides ├── lib/ # Server-side libraries and classes │ ├── app.inc.php # Application bootstrap and global helpers │ ├── compatibility.inc.php # Backwards compatibility utilities │ └── classes/ # Core server classes and libraries │ ├── aps_base.inc.php # APS service base class (deprecated) │ ├── backup.inc.php # Backup management │ ├── cli.inc.php # CLI dispatch logic │ ├── cron.d/ # Cron job definitions │ ├── tpl.inc.php # Template engine core │ └── ... # Other class files ├── mods-available/ # Available server modules ├── mods-core/ # Core server modules ├── mods-enabled/ # Enabled server modules (symlinks) ├── plugins-available/ # Available plugins ├── plugins-enabled/ # Enabled plugins (symlinks) ├── scripts/ # Daemon and script utilities └── temp/ # Temporary files and caches ``` ---------------------------------------- TITLE: ISPConfig Web Interface Directory Structure (Bash) DESCRIPTION: This snippet details the directory structure for the ISPConfig web interface, located at /usr/local/ispconfig/interface/. It contains directories for ACME challenges, cache, libraries, SSL certificates, temporary files, tools, and the main web assets organized by module. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/folder-structure.md#_snippet_1 LANGUAGE: bash CODE: ``` interface/ ├── acme/ # ACME (Let's Encrypt) challenge response scripts ├── cache/ # Compiled template and data cache ├── lib/ │ ├── app.inc.php # Application bootstrap and global helpers │ ├── classes/ # Core PHP classes and libraries │ ├── compatibility.inc.php # Backwards compatibility utilities │ ├── config.inc.php # Main configuration file (DB credentials, paths) for the UI │ ├── lang/ # Global language files (en.lang, de.lang, ...) │ ├── plugins/ # Interface plugins │ ├── server_conf.master # Template for server-specific configuration │ └── shelluser_blacklist # Blacklist for shell user creation ├── ssl/ # SSL Certificates for the UI and apps vhost ├── temp/ # Temporary files and uploads ├── tools/ # CLI and maintenance scripts └── web/ ├── js/ # JavaScript assets ├── themes/ # CSS, images, layout templates ├── admin/ # Admin interface module ├── client/ # Client interface module ├── dashboard/ # Summary dashboard module ├── dns/ # DNS management module ├── help/ # Help and documentation module ├── login/ # Login module ├── mail/ # Mail server module ├── mailuser/ # Mailuser login module ├── monitor/ # Monitoring and status module ├── remote/ # Remote API endpoint ├── sites/ # Website management module ├── strengthmeter/ # Password strength meter code ├── temp/ # Temporary web scripts ├── tools/ # Web-based tools and utilities ├── vm/ # OpenVZ Virtual machine management module (deprecated) └── /... # Other modules ``` ---------------------------------------- TITLE: Configuring Field with SQL Datasource and Static Options (PHP) DESCRIPTION: This complete ISPConfig tform field definition in PHP demonstrates how to configure a 'SELECT' field ('client_id') using a SQL datasource. It includes static options ('value'), the SQL query ('querystring') utilizing the '{AUTHSQL}' placeholder for authorization, and specifies the 'keyfield' and 'valuefield' for mapping query results to options. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-datasource.md#_snippet_2 LANGUAGE: PHP CODE: ``` 'client_id' => [ 'datatype' => 'INTEGER', 'formtype' => 'SELECT', 'default' => '', 'value' => [0 => 'Select Client'], 'datasource' => [ 'type' => 'SQL', 'querystring' => 'SELECT `client_id`, `contact_name` FROM `client` WHERE {AUTHSQL} ORDER BY `contact_name`', 'keyfield' => 'client_id', 'valuefield' => 'contact_name' ] ] ``` ---------------------------------------- TITLE: Defining SQL Datasource in ISPConfig tform (PHP) DESCRIPTION: This snippet shows how to configure a field's `datasource` setting to fetch dynamic values from a database using an SQL query. It specifies the query, the key field for the value, and the value field for display. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-settings.md#_snippet_0 LANGUAGE: php CODE: ``` 'datasource' => [ 'type' => 'SQL', 'querystring' => 'SELECT id, name FROM table', 'keyfield' => 'id', 'valuefield' => 'name' ] ``` ---------------------------------------- TITLE: Apply IDNTOUTF8 Filter (ISPConfig tform) - PHP DESCRIPTION: Configures an ISPConfig tform field filter to convert ASCII (Punycode) domain names back to their UTF-8 representation. This filter is applied during the 'SHOW' event, typically before displaying the value to the user. It makes domain names readable for international users. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-filters.md#_snippet_1 LANGUAGE: php CODE: ``` 'filters' => [ [ 'event' => 'SHOW', 'type' => 'IDNTOUTF8' ] ] ``` ---------------------------------------- TITLE: Defining SQL Datasource Configuration (PHP) DESCRIPTION: This PHP array snippet shows the structure for configuring a SQL datasource within an ISPConfig tform field definition. It specifies the type as 'SQL', provides the SQL query string, and identifies the database fields to use for option values ('keyfield') and labels ('valuefield'). SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-datasource.md#_snippet_0 LANGUAGE: PHP CODE: ``` 'datasource' => [ 'type' => 'SQL', 'querystring' => 'SELECT `server_id`, `server_name` FROM `server` WHERE `mail_server` = 1 ORDER BY `server_name`', 'keyfield' => 'server_id', 'valuefield' => 'server_name' ] ``` ---------------------------------------- TITLE: Template for Textarea Field (HTML) DESCRIPTION: Shows the HTML template structure for a multi-line text input field (textarea) in the ISPConfig Form System. It uses template variables for the label and the field value. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-types.md#_snippet_15 LANGUAGE: html CODE: ```
``` ---------------------------------------- TITLE: Configuring Form Tabs and Fields in PHP DESCRIPTION: This snippet demonstrates how to define form tabs and their contained fields within the `$form["tabs"]` array. Each tab is an associative array specifying its title, template file, optional width, and a 'fields' array. Each field within the 'fields' array is configured with properties like datatype, formtype, datasource (e.g., SQL query), filters (for SAVE/SHOW events), validators (with error messages), default value, and optional value override. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-file-structure.md#_snippet_1 LANGUAGE: php CODE: ``` $form["tabs"]["domain"] = [ 'title' => "Domain", 'template' => "templates/mail_domain_edit.htm", 'width' => 100, // optional 'fields' => [ 'server_id' => [ 'datatype' => 'INTEGER', 'formtype' => 'SELECT', 'default' => '', 'datasource' => [ 'type' => 'SQL', 'querystring' => 'SELECT server_id,server_name ...', 'keyfield' => 'server_id', 'valuefield' => 'server_name' ], 'value' => '' // optional override ], 'domain' => [ 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', 'filters' => [ ['event'=>'SAVE','type'=>'IDNTOASCII'], ['event'=>'SHOW','type'=>'IDNTOUTF8'], ['event'=>'SAVE','type'=>'TOLOWER'] ], 'validators' => [ ['type'=>'NOTEMPTY','errmsg'=>'domain_error_empty'], ['type'=>'ISDOMAIN','errmsg'=>'domain_error_regex'], ['type'=>'CUSTOM','class'=>'validate_mail_transport','function'=>'validate_isnot_mailtransport','errmsg'=>'domain_is_transport'] ], 'default' => '', 'value' => '' // optional override ] // ... other fields ] ]; ``` ---------------------------------------- TITLE: Template for Radio Button Group (HTML) DESCRIPTION: Demonstrates the HTML structure for rendering a group of radio buttons using ISPConfig template variables. The {tmpl_var name='type'} placeholder is replaced by the actual radio button HTML. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-types.md#_snippet_14 LANGUAGE: html CODE: ```
{tmpl_var name='type'}
``` ---------------------------------------- TITLE: Apply IDNTOASCII Filter (ISPConfig tform) - PHP DESCRIPTION: Configures an ISPConfig tform field filter to convert Internationalized Domain Names (IDNs) to their ASCII (Punycode) representation. This filter is applied during the 'SAVE' event, typically before storing the value in the database. It ensures domain names are stored in a standardized format. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-filters.md#_snippet_0 LANGUAGE: php CODE: ``` 'filters' => [ [ 'event' => 'SAVE', 'type' => 'IDNTOASCII' ] ] ``` ---------------------------------------- TITLE: Apply NORMALIZEPATH Filter (ISPConfig tform) - PHP DESCRIPTION: Configures an ISPConfig tform field filter to normalize filesystem paths. This includes resolving '..' and '.' segments, standardizing directory separators, and removing redundant slashes. This filter is applied during the 'SAVE' event to ensure paths are stored in a consistent and secure format. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-filters.md#_snippet_9 LANGUAGE: php CODE: ``` 'filters' => [ [ 'event' => 'SAVE', 'type' => 'NORMALIZEPATH' ] ] ``` ---------------------------------------- TITLE: Apply TOUPPER Filter (ISPConfig tform) - PHP DESCRIPTION: Configures an ISPConfig tform field filter to convert the input value to uppercase. This filter is applied during the 'SAVE' event, typically before storing the value in the database. It is useful for standardizing input where uppercase is required. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-filters.md#_snippet_3 LANGUAGE: php CODE: ``` 'filters' => [ [ 'event' => 'SAVE', 'type' => 'TOUPPER' ] ] ``` ---------------------------------------- TITLE: Apply TRIM Filter (ISPConfig tform) - PHP DESCRIPTION: Configures an ISPConfig tform field filter to remove leading and trailing whitespace from the input value. This filter is applied during the 'SAVE' event, typically before storing the value in the database. It helps clean up user input. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-filters.md#_snippet_5 LANGUAGE: php CODE: ``` 'filters' => [ [ 'event' => 'SAVE', 'type' => 'TRIM' ] ] ``` ---------------------------------------- TITLE: Defining CUSTOM Datasource Configuration (PHP) DESCRIPTION: This PHP array snippet illustrates the configuration for a CUSTOM datasource in an ISPConfig tform field definition. It sets the type to 'CUSTOM' and specifies the PHP class and function that will be called to dynamically generate the field options. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-datasource.md#_snippet_1 LANGUAGE: PHP CODE: ``` 'datasource' => [ 'type' => 'CUSTOM', 'class' => 'my_custom_class', 'function' => 'get_options' ] ``` ---------------------------------------- TITLE: Defining Custom Datasource in ISPConfig tform (PHP) DESCRIPTION: This snippet demonstrates how to configure a field's `datasource` setting to use a custom PHP class and function to generate dynamic values. It specifies the class name and the function name to be called. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-settings.md#_snippet_1 LANGUAGE: php CODE: ``` 'datasource' => [ 'type' => 'CUSTOM', 'class' => 'my_class', 'function' => 'my_function' ] ``` ---------------------------------------- TITLE: Defining TEXT Field Type in ISPConfig tform (PHP) DESCRIPTION: Configuration array for a single-line text input field in the ISPConfig tform system. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-types.md#_snippet_0 LANGUAGE: PHP CODE: ``` 'fieldname' => [ 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', 'default' => '', 'validators' => [], 'value' => '' ] ``` ---------------------------------------- TITLE: Defining TEXTAREA Field Type in ISPConfig tform (PHP) DESCRIPTION: Configuration array for a multi-line text input field in the ISPConfig tform system. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-types.md#_snippet_1 LANGUAGE: PHP CODE: ``` 'fieldname' => [ 'datatype' => 'TEXT', 'formtype' => 'TEXTAREA', 'default' => '', 'validators' => [], 'value' => '' ] ``` ---------------------------------------- TITLE: Apply TOLOWER Filter (ISPConfig tform) - PHP DESCRIPTION: Configures an ISPConfig tform field filter to convert the input value to lowercase. This filter is applied during the 'SAVE' event, typically before storing the value in the database. It is useful for ensuring case-insensitive comparisons or standardizing input. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-filters.md#_snippet_2 LANGUAGE: php CODE: ``` 'filters' => [ [ 'event' => 'SAVE', 'type' => 'TOLOWER' ] ] ``` ---------------------------------------- TITLE: Configuring Field with CUSTOM Datasource (PHP) DESCRIPTION: This PHP snippet provides a complete ISPConfig tform field definition ('custom_field') configured to use a CUSTOM datasource. It specifies the field's datatype and formtype, and defines the datasource by referencing a custom PHP class and function responsible for generating the field's options dynamically. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-datasource.md#_snippet_3 LANGUAGE: PHP CODE: ``` 'custom_field' => [ 'datatype' => 'VARCHAR', 'formtype' => 'SELECT', 'datasource' => [ 'type' => 'CUSTOM', 'class' => 'my_custom_class', 'function' => 'get_options' ] ] ``` ---------------------------------------- TITLE: Using NOTEMPTY Validator in ISPConfig tform (PHP) DESCRIPTION: Configures a form field validator in ISPConfig's tform system to ensure the field is not left empty. The `errmsg` key specifies the error message or its translation key to display if the validation fails. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-validators.md#_snippet_0 LANGUAGE: php CODE: ``` 'validators' => [ [ 'type' => 'NOTEMPTY', 'errmsg' => 'field_required_error' ] ] ``` ---------------------------------------- TITLE: Using REGEX Validator in ISPConfig tform (PHP) DESCRIPTION: Configures a form field validator in ISPConfig's tform system to validate the field's value against a specified regular expression pattern. The `regex` key holds the pattern, and `errmsg` provides the error message. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-validators.md#_snippet_1 LANGUAGE: php CODE: ``` 'validators' => [ [ 'type' => 'REGEX', 'regex' => '/^([0-9]{1,5})$/', 'errmsg' => 'field_error_regex' ] ] ``` ---------------------------------------- TITLE: Defining MULTIPLE Field Type in ISPConfig tform (PHP) DESCRIPTION: Configuration array for a field that allows selection of multiple values from a list, rendering as a multi-select dropdown in the ISPConfig tform system. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-types.md#_snippet_7 LANGUAGE: PHP CODE: ``` 'fieldname' => [ 'datatype' => 'VARCHAR', 'formtype' => 'MULTIPLE', 'separator' => ',', 'value' => ['1' => 'Option 1', '2' => 'Option 2', '3' => 'Option 3'] ] ``` ---------------------------------------- TITLE: Defining SELECT Field Type in ISPConfig tform (PHP) DESCRIPTION: Configuration array for a dropdown select field in the ISPConfig tform system. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-types.md#_snippet_4 LANGUAGE: PHP CODE: ``` 'fieldname' => [ 'datatype' => 'VARCHAR', 'formtype' => 'SELECT', 'default' => '', 'value' => ['option1' => 'Option 1', 'option2' => 'Option 2'] ] ``` ---------------------------------------- TITLE: Apply TOLATIN1 Filter (ISPConfig tform) - PHP DESCRIPTION: Configures an ISPConfig tform field filter to convert the input value to ISO-8859-1 (Latin-1) encoding. This filter is applied during the 'SAVE' event, typically before storing the value in the database. It is used for compatibility with systems or databases expecting this specific encoding. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-filters.md#_snippet_4 LANGUAGE: php CODE: ``` 'filters' => [ [ 'event' => 'SAVE', 'type' => 'TOLATIN1' ] ] ``` ---------------------------------------- TITLE: Defining a Domain Form Field in PHP DESCRIPTION: This PHP array defines the structure and validation rules for a 'domain' form field. It specifies the data type, form input type, default value, filters applied on save and show events (like IDN conversion and lowercasing), and validators to ensure the field is not empty, is a valid domain format, and passes custom validation. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-settings.md#_snippet_2 LANGUAGE: php CODE: ``` 'domain' => [ 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', 'default' => '', 'filters' => [ ['event' => 'SAVE', 'type' => 'IDNTOASCII'], ['event' => 'SHOW', 'type' => 'IDNTOUTF8'], ['event' => 'SAVE', 'type' => 'TOLOWER'] ], 'validators' => [ ['type' => 'NOTEMPTY', 'errmsg' => 'domain_error_empty'], ['type' => 'ISDOMAIN', 'errmsg' => 'domain_error_regex'], ['type' => 'CUSTOM', 'class' => 'validate_mail_transport', 'function' => 'validate_domain'] ] ] ``` ---------------------------------------- TITLE: Using ISASCII Validator in ISPConfig tform (PHP) DESCRIPTION: Configures a form field validator in ISPConfig's tform system to ensure that the field's value contains only ASCII characters. The `errmsg` key specifies the error message. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-validators.md#_snippet_5 LANGUAGE: php CODE: ``` 'validators' => [ [ 'type' => 'ISASCII', 'errmsg' => 'Value must be ASCII only.' ] ] ``` ---------------------------------------- TITLE: Using ISDOMAIN Validator in ISPConfig tform (PHP) DESCRIPTION: Configures a form field validator in ISPConfig's tform system to check if the field's value is a valid domain name. The `errmsg` key specifies the error message. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-validators.md#_snippet_6 LANGUAGE: php CODE: ``` 'validators' => [ [ 'type' => 'ISDOMAIN', 'errmsg' => 'Invalid domain name.' ] ] ``` ---------------------------------------- TITLE: Defining RADIO Field Type in ISPConfig tform (PHP) DESCRIPTION: Configuration array for a radio button group in the ISPConfig tform system. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-types.md#_snippet_5 LANGUAGE: PHP CODE: ``` 'fieldname' => [ 'datatype' => 'VARCHAR', 'formtype' => 'RADIO', 'default' => '', 'value' => ['option1' => 'Option 1', 'option2' => 'Option 2'] ] ``` ---------------------------------------- TITLE: Apply NOWHITESPACE Filter (ISPConfig tform) - PHP DESCRIPTION: Configures an ISPConfig tform field filter to remove all whitespace characters (spaces, tabs, newlines, etc.) from the input value. This filter is applied during the 'SAVE' event, typically before storing the value in the database. It is useful for fields where whitespace is not allowed, like usernames or codes. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-filters.md#_snippet_6 LANGUAGE: php CODE: ``` 'filters' => [ [ 'event' => 'SAVE', 'type' => 'NOWHITESPACE' ] ] ``` ---------------------------------------- TITLE: Apply STRIPNL Filter (ISPConfig tform) - PHP DESCRIPTION: Configures an ISPConfig tform field filter to remove newline characters (\n, \r) from the input value. This filter is applied during the 'SAVE' event, typically before storing the value in the database. It is useful for single-line text fields. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-filters.md#_snippet_8 LANGUAGE: php CODE: ``` 'filters' => [ [ 'event' => 'SAVE', 'type' => 'STRIPNL' ] ] ``` ---------------------------------------- TITLE: Defining PASSWORD Field Type in ISPConfig tform (PHP) DESCRIPTION: Configuration array for a password input field (masked input) in the ISPConfig tform system. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-types.md#_snippet_6 LANGUAGE: PHP CODE: ``` 'fieldname' => [ 'datatype' => 'VARCHAR', 'formtype' => 'PASSWORD', 'default' => '', 'validators' => [], 'value' => '' ] ``` ---------------------------------------- TITLE: Apply STRIPTAGS Filter (ISPConfig tform) - PHP DESCRIPTION: Configures an ISPConfig tform field filter to remove HTML and PHP tags from the input value. This filter is applied during the 'SAVE' event, typically before storing the value in the database. It is a basic security measure to prevent XSS or code injection in fields that should only contain plain text. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-filters.md#_snippet_7 LANGUAGE: php CODE: ``` 'filters' => [ [ 'event' => 'SAVE', 'type' => 'STRIPTAGS' ] ] ``` ---------------------------------------- TITLE: Defining CHECKBOX Field Type in ISPConfig tform (PHP) DESCRIPTION: Configuration array for a single checkbox input field in the ISPConfig tform system. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-types.md#_snippet_2 LANGUAGE: PHP CODE: ``` 'fieldname' => [ 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', 'default' => 'n', 'value' => ['y' => 'Yes', 'n' => 'No'] ] ``` ---------------------------------------- TITLE: Using ISEMAILADDRESS Validator in ISPConfig tform (PHP) DESCRIPTION: Configures a form field validator in ISPConfig's tform system to check if the field's value is a valid email address using standard validation rules. The `errmsg` key specifies the error message. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-validators.md#_snippet_8 LANGUAGE: php CODE: ``` 'validators' => [ [ 'type' => 'ISEMAILADDRESS', 'errmsg' => 'Invalid email address.' ] ] ``` ---------------------------------------- TITLE: Defining CHECKBOXARRAY Field Type in ISPConfig tform (PHP) DESCRIPTION: Configuration array for multiple checkbox inputs (array of checkboxes) in the ISPConfig tform system. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-field-types.md#_snippet_3 LANGUAGE: PHP CODE: ``` 'fieldname' => [ 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOXARRAY', 'default' => '', 'value' => ['option1' => 'Option 1', 'option2' => 'Option 2'] ] ``` ---------------------------------------- TITLE: Using ISPOSITIVE Validator in ISPConfig tform (PHP) DESCRIPTION: Configures a form field validator in ISPConfig's tform system to check if the field's value is a positive number. The `errmsg` key specifies the error message or its translation key. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-validators.md#_snippet_3 LANGUAGE: php CODE: ``` 'validators' => [ [ 'type' => 'ISPOSITIVE', 'errmsg' => 'value_must_be_positive' ] ] ``` ---------------------------------------- TITLE: Using CUSTOM Validator in ISPConfig tform (PHP) DESCRIPTION: Configures a form field validator in ISPConfig's tform system to use a custom PHP class and function for validation logic. The `class` and `function` keys specify the callable, and `errmsg` provides the error message. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-validators.md#_snippet_2 LANGUAGE: php CODE: ``` 'validators' => [ [ 'type' => 'CUSTOM', 'class' => 'validate_domain', 'function' => 'web_domain_autosub', 'errmsg' => 'domain_error_autosub' ] ] ``` ---------------------------------------- TITLE: Using ISEMAIL Validator in ISPConfig tform (PHP) DESCRIPTION: Configures a form field validator in ISPConfig's tform system to check if the field's value is a valid email address using stricter validation rules (e.g., disallowing plus signs in the local part). The `errmsg` key specifies the error message. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-validators.md#_snippet_7 LANGUAGE: php CODE: ``` 'validators' => [ [ 'type' => 'ISEMAIL', 'errmsg' => 'Invalid email address.' ] ] ``` ---------------------------------------- TITLE: Using UNIQUE Validator in ISPConfig tform (PHP) DESCRIPTION: Configures a form field validator in ISPConfig's tform system to check if the field's value is unique within the relevant database table. The `errmsg` key specifies the error message or its translation key. SOURCE: https://github.com/ispconfig/ispconfig3-dev-docs/blob/main/tform/form-validators.md#_snippet_4 LANGUAGE: php CODE: ``` 'validators' => [ [ 'type' => 'UNIQUE', 'errmsg' => 'value_must_be_unique' ] ] ```