🔧
System

Custom Fields (Variables)

Admin Settings

Extensible custom fields for any entity with granular permissions

Overview

Flexible custom field system (Variables) that extends any entity with additional metadata. Supports 14 data types (string, integer, float, boolean, text, JSON, date, datetime, file, color, URL, email, select, multiselect). Includes per-variable view/edit role permissions, validation, encryption, and grouping.

Design Considerations

UX patterns and visual design notes for this feature:

  • Variables shown as separate tab in user settings
  • Group related variables together for better UX
  • Use appropriate input widgets per data type
  • Sensitive variables (SSN, tax ID) should be encrypted
  • Select/multiselect need predefined options in JSON config

Key Benefits

What makes this feature stand out:

  • 14 data types supported
  • Granular role-based permissions per variable
  • Apply to any entity (User, Organization, Product, etc.)
  • Encryption support for sensitive data
  • Custom validation rules (Yii2 validators)
  • Grouping and ordering for organization
  • Render as form fields automatically
Technical Note

Variable model defines field schema. VariableValue stores actual values per entity. VariableHelper::getForEntity() retrieves values. VariableHelper::saveForEntity() persists values. Use VariableHelper::renderInput() to generate form fields. Variables are scoped to entity_type.

Helpers
VariableHelper
Models
VariableVariableValue
Database Tables
variablevariable_value

Configuration

Config Relationship Legend
DB overrides params.php🔗 DB related setting📋 DB stores value only
params.php Configuration

Config path: params['variables']

params['features']['variables'] => trueparams['variables']['enableUserVariables'] => trueparams['variables']['enableOrganizationVariables'] => true
Note: Variables configuration is entity-scoped. Create variables via admin panel (/admin/variables). Each variable has entity_type, data_type, and permissions. Values stored in variable_value table.