From ab4ae6bdd068e3ecd1e5f40e544d90bb50231b1f Mon Sep 17 00:00:00 2001 From: yuriinalivaiko Date: Sat, 28 Oct 2023 13:12:24 +0300 Subject: [PATCH] - fixed the Required condition validation for the Number field. --- includes/core/um-actions-form.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/core/um-actions-form.php b/includes/core/um-actions-form.php index 643f8f68..978d36d5 100644 --- a/includes/core/um-actions-form.php +++ b/includes/core/um-actions-form.php @@ -513,6 +513,12 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) { } } + // Validate the Required condition for the Number field. Set the Minimum Number option to allow 0 value. + if ( isset( $array['type'] ) && 'number' === $array['type'] && ! isset( $array['min'] ) && ! empty( $array['required'] ) && empty( $submitted_data[ $key ] ) ) { + // translators: %s: title. + UM()->form()->add_error( $key, sprintf( __( '%s is required.', 'ultimate-member' ), $array['title'] ) ); + } + if ( isset( $array['type'] ) && $array['type'] == 'checkbox' && isset( $array['required'] ) && $array['required'] == 1 && ! isset( $submitted_data[ $key ] ) ) { // translators: %s: title. UM()->form()->add_error( $key, sprintf( __( '%s is required.', 'ultimate-member' ), $array['title'] ) );