diff --git a/classes/models/FrmFieldFormHtml.php b/classes/models/FrmFieldFormHtml.php index 32ca4f120f..f0938448c2 100644 --- a/classes/models/FrmFieldFormHtml.php +++ b/classes/models/FrmFieldFormHtml.php @@ -292,16 +292,26 @@ private function replace_error_shortcode() { $this->maybe_add_error_id(); $error = $this->pass_args['errors'][ 'field' . $this->field_id ] ?? false; - if ( $error && ! str_contains( $this->html, 'role="alert"' ) && FrmAppHelper::should_include_alert_role_on_field_errors() ) { + if ( ! $error ) { + FrmShortcodeHelper::remove_inline_conditions( false, 'error', $error, $this->html ); + return; + } + + $include_alert_role_on_field_errors = FrmAppHelper::should_include_alert_role_on_field_errors(); + $has_alert_role = str_contains( $this->html, 'role="alert"' ); + + if ( ! $has_alert_role && $include_alert_role_on_field_errors ) { $error_body = self::get_error_body( $this->html ); if ( is_string( $error_body ) && ! str_contains( $error_body, 'role=' ) ) { $new_error_body = preg_replace( '/class="frm_error/', 'role="alert" class="frm_error', $error_body, 1 ); $this->html = str_replace( '[if error]' . $error_body . '[/if error]', '[if error]' . $new_error_body . '[/if error]', $this->html ); } + } elseif ( ! $include_alert_role_on_field_errors && $has_alert_role ) { + $this->html = str_replace( 'role="alert"', '', $this->html ); } - FrmShortcodeHelper::remove_inline_conditions( ! empty( $error ), 'error', $error, $this->html ); + FrmShortcodeHelper::remove_inline_conditions( true, 'error', $error, $this->html ); } /** diff --git a/classes/models/fields/FrmFieldTextarea.php b/classes/models/fields/FrmFieldTextarea.php index 57c27d5575..b7571404db 100644 --- a/classes/models/fields/FrmFieldTextarea.php +++ b/classes/models/fields/FrmFieldTextarea.php @@ -98,8 +98,7 @@ public function show_default_value_field( $field, $default_name, $default_value */ public function front_field_input( $args, $shortcode_atts ) { $input_html = $this->get_field_input_html_hook( $this->field ); - $this->add_aria_description( $args, $input_html ); - $rows = $this->field['max'] ? 'rows="' . esc_attr( $this->field['max'] ) . '" ' : ''; + $rows = $this->field['max'] ? 'rows="' . esc_attr( $this->field['max'] ) . '" ' : ''; // phpcs:disable Generic.WhiteSpace.ScopeIndent return '