title: "Add New Field" post_status: publish comment_status: open taxonomy: category: - elementor-developers-docs post_tag: - Form Fields - Src - Repos
Add New Field
The Form widget has built-in field types, but it also accepts new fields registered by external developers.
Registering Fields
To register new fields just initiate the field class:
function register_new_form_fields( $form_fields_registrar ) {
require_once( __DIR__ . '/forms/fields/field-1.php' );
require_once( __DIR__ . '/forms/fields/field-2.php' );
$form_fields_registrar->register( new \Field_1() );
$form_fields_registrar->register( new \Field_2() );
}
add_action( 'elementor_pro/forms/fields/register', 'register_new_form_fields' );
This hooks to the elementor_pro/forms/fields/register action hook which holds the form registrar manager. The manager then registers the new fields by passing the field instances.