statikbe / craft-config-values
Populate a field with values from the plugin's config
Installs: 9 202
Dependents: 2
Suggesters: 0
Security: 0
Stars: 4
Watchers: 5
Forks: 0
Open Issues: 2
Type:craft-plugin
Requires
- craftcms/cms: ^5.0.0-beta.1
Requires (Dev)
- craftcms/ecs: dev-main
- craftcms/phpstan: dev-main
This package is auto-updated.
Last update: 2025-06-23 14:11:22 UTC
README
Populate field options from a centralized configuration file, providing consistent predefined values across multiple fields without hardcoding them into individual field settings.
Requirements
This plugin requires Craft CMS 5.0.0 or later.
Features
Installation
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Install via Composer:
composer require statikbe/craft-config-values
-
Install the plugin via Craft CLI:
./craft plugin/install config-values-field
Configuration
Create a configuration file at config/config-values-field.php
:
<?php return [ 'data' => [ // Basic dropdown/radio/checkbox options 'ctaStyles' => [ 'primary' => 'Primary Button', 'secondary' => 'Secondary Button', 'outline' => 'Outline Button', 'link' => 'Text Link', ], // Color options (supports hex values) 'brandColors' => [ '' => 'none', // Special: shows striped pattern 'random' => 'random', // Special: shows rainbow gradient 'primary' => '#3B82F6', 'secondary' => '#10B981', 'accent' => '#F59E0B', 'danger' => '#EF4444', ], // Gradient colors (2-3 colors) 'headerColors' => [ '' => 'none', // Special: shows striped pattern 'random' => 'random', // Special: shows rainbow gradient 'sunset' => ['#FF6B6B', '#FFE66D'], 'ocean' => ['#667eea', '#764ba2', '#f093fb'], 'forest' => ['#134e5e', '#71b280'], ], // Shape options (requires SVG files) 'icons' => [ 'path' => '@webroot/assets/icons/', 'shapes' => [ '' => 'none', 'random' => 'random', 'arrow' => 'Arrow', 'star' => 'Star', 'heart' => 'Heart', 'check' => 'Checkmark', ], ], ], ];
Field Types
The plugin supports 5 different field display types:
1. Dropdown
Standard select dropdown for single selection.
2. Radio Buttons
Radio button group for single selection with visual options.
3. Checkboxes
Multiple selection checkboxes for choosing multiple values.
4. Color
Visual color picker with special features:
- Hex colors: Display as color swatches
- Gradients: Support 2-3 color arrays for gradient backgrounds
- Special values:
'random'
: Shows rainbow gradient indicator'none'
: Shows striped "no color" pattern
5. Shape
SVG shape selector for icon/graphic selection:
- Requires
path
configuration pointing to SVG directory - Uses
shapes
array to map filenames to labels - Validates file existence
- Special values
'random'
'none'
Brought to you by Statik.be