Skip to main content

Dropdown

Type: dropdown

Description

Dropdown select field with predefined options.

Screenshot

Dropdown

Basic Usage

[
"type" => "dropdown",
"heading" => __("Field Label", "your-text-domain"),
"param_name" => "your_param_name",
"value" => [
__("Option 1", "your-text-domain") => "value1",
__("Option 2", "your-text-domain") => "value2",
__("Option 3", "your-text-domain") => "value3",
],
"std" => "value1", // Default value
"description" => __("Field description", "your-text-domain"),
]

Common Parameters

All param types support these common parameters:

ParameterTypeDescription
typeStringRequired. Must be "dropdown"
holderStringHTML tag name where the value is displayed in backend edit mode. Default: hidden input
classStringCSS class added to the holder HTML tag
headingStringLabel shown in the editor interface
param_nameStringRequired. Parameter name used in shortcode
valueMixedValue for the parameter
descriptionStringHelp text shown below the field
groupStringTab/group name to organize parameters
sectionStringSection slug to visually group params within a tab
weightIntegerDisplay order (higher = shows first)
edit_field_classStringCSS class for field width (e.g., "vc_col-sm-6")
dependencyArrayShow/hide based on other field values
admin_labelBooleanShow value in element title bar
param_holder_classStringCSS class for the param wrapper in the edit element modal
save_alwaysBooleanForce saving the value even if it equals the default or is empty
callbackArrayJavaScript function callback (e.g., ['after_add' => 'myCallback'])
settingsArrayType-specific configuration options (see Type-Specific Parameters below)
deprecatedStringVersion in which the param was deprecated

Type-Specific Parameters

ParameterTypeDefaultDescription
stdString-Default selected value
settingsArray-Configuration array with the following options:
    typeArray-Describes specific dropdown variations (used internally with grids)
    searchBooleanfalseEnable search/filter functionality. Recommended for dropdowns with 10+ options

Complete Example

<?php
add_action('vc_before_init', 'my_element_with_dropdown');
function my_element_with_dropdown() {
vc_map([
"name" => __("My Element", "domain"),
"base" => "my_element",
"category" => __("My Category", "domain"),
"params" => [
[
"type" => "dropdown",
"heading" => __("Style", "domain"),
"param_name" => "style",
"value" => [
__("Default", "domain") => "default",
__("Modern", "domain") => "modern",
__("Classic", "domain") => "classic",
],
"std" => "default",
"description" => __("Select element style", "domain"),
"settings" => ["search" => true], // Enable search for long lists
],
],
]);
}