title: "Control Values" post_status: publish comment_status: open taxonomy: category: - elementor-developers-docs post_tag: - Controls - Src - Repos
Control Values
You can set custom default values for your control. For example, if you add a new field, you can define its default value.
Control Default Value
Set the default values to display when initializing the control. Note that some controls return a single value (strings, numbers, bool etc.), while other controls return arrays. Make sure you set a default value with the same data type.
The following will set a default value for a data control, which will return a single value:
class Elementor_Test_Control extends \Elementor\Base_Data_Control {
public function get_type(): string {
return 'continents-control';
}
protected function get_default_settings(): array {
return [
'continents' => [ 'Asia', 'Africa', 'Europe', 'North America', 'South America', 'Australia/Oceania', 'Antarctica', ]
];
}
public function get_default_value(): string {
return 'Europe';
}
}
Overriding Default Values
When controls are used in widgets, you can either use the default value set by the control or override it and set your own default values:
```php {14-21,23-31}
start_controls_section( 'section_content', [ 'label' => esc_html__( 'Content', 'textdomain' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); // Control default value will be used, i.e. 'Europe' $this->add_control( 'continent_1', [ 'label' => esc_html__( 'Continent 1', 'textdomain' ), 'type' => 'continents-control', ] ); // Custom default value will be used, i.e. 'North America' $this->add_control( 'continent_2', [ 'label' => esc_html__( 'Continent 2', 'textdomain' ), 'type' => 'continents-control', 'default' => 'North America', ] ); $this->end_controls_section(); } } ``` ?>