Skip to content

Commit ae7ba19

Browse files
authored
Updated form validation documentation (#280)
`$forms_module->field_types['tel']` returns null and it can't remove the action. To make it work I updated that part to use `$forms_module->fields_registrar->get( 'tel' )`.
1 parent 7105bdc commit ae7ba19

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/hooks/form-validation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Tel match this format XXX-XXX-XXXX, i.e. 123-456-7890
6161
function elementor_form_tel_field_validation( $field, $record, $ajax_handler ) {
6262
// Remove native validation
6363
$forms_module = \ElementorPro\Plugin::instance()->modules_manager->get_modules( 'forms' );
64-
remove_action( 'elementor_pro/forms/validation/tel', [ $forms_module->field_types['tel'], 'validation' ] );
64+
remove_action( 'elementor_pro/forms/validation/tel', [ $forms_module->fields_registrar->get( 'tel' ), 'validation' ], 10, 3 );
6565

6666
// Run your own validation, ex:
6767
if ( empty( $field['value'] ) ) {
@@ -78,7 +78,7 @@ add_action( 'elementor_pro/forms/validation/tel', 'elementor_form_tel_field_vali
7878
function elementor_form_tel_field_rendering( $item, $item_index, $form ) {
7979
// Remove native render
8080
$forms_module = \ElementorPro\Plugin::instance()->modules_manager->get_modules( 'forms' );
81-
remove_action( 'elementor_pro/forms/render_field/tel', [$forms_module->field_types['tel'] , 'field_render' ], 10, 3 );
81+
remove_action( 'elementor_pro/forms/render_field/tel', [ $forms_module->fields_registrar->get( 'tel' ), 'field_render' ], 10, 3 );
8282

8383
// Add custom render ex:
8484
$form->add_render_attribute( 'input' . $item_index, 'class', 'elementor-field-textual' );

0 commit comments

Comments
 (0)