# Action Controls
Elementor Pro AdvancedEach action can incorporate controls (setting fields), that allow users to select their data. When a user selects an action with these controls the control will be activated. Data entered into those fields is saved in the database and later used when triggering the action.
# Registering Controls
In your action class, you can add controls using the register_settings_section()
method as follows:
class Elementor_Test_Action extends \ElementorPro\Modules\Forms\Classes\Action_Base {
protected function register_settings_section( $widget ): void {
$widget->start_controls_section();
$widget->add_control();
$widget->add_control();
$widget->add_control();
$widget->end_controls_section();
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- Action Controls – The
register_settings_section()
method lets you define which controls (setting fields) the action will have. The$widget
parameter is an instance of the form widget.
# Add Controls to your Action
In the example below, we're going to add a few controls to the widget instance to allow users to save additional data:
class Elementor_Test_Action extends \ElementorPro\Modules\Forms\Classes\Action_Base {
public function register_settings_section( $widget ): void {
$widget->start_controls_section(
'custom_action_section',
[
'label' => esc_html__( 'Custom Action', 'textdomain' ),
'condition' => [
'submit_actions' => $this->get_name(),
],
]
);
$widget->add_control(
'custom_action_api_key',
[
'label' => esc_html__( 'API Key', 'textdomain' ),
'type' => \Elementor\Controls_Manager::TEXT,
]
);
$widget->add_control(
'custom_action_app_id',
[
'label' => esc_html__( 'App ID', 'textdomain' ),
'type' => \Elementor\Controls_Manager::TEXT,
]
);
$widget->end_controls_section();
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Please note that we recommend adding an entire setting section dedicated to your custom action.
In addition, you should only use conditional display, to show the section if the submit_action
control in the form widget contains your custom action. This way, the entire section is displayed only when the user selects this particular action.