| @@ -229,9 +229,9 @@ | ||
| 229 | 229 | * @since 3.0 |
| 230 | 230 | */ |
| 231 | 231 | private function replace_error_shortcode() { |
| 232 | 232 | $this->maybe_add_error_id(); |
| 233 | - $error = $this->pass_args['errors'][ 'field' . $this->field_id ] ?? false; | |
| 233 | + $error = isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ? $this->pass_args['errors'][ 'field' . $this->field_id ] : false; | |
| 234 | 234 | |
| 235 | 235 | if ( ! empty( $error ) && false === strpos( $this->html, 'role="alert"' ) && FrmAppHelper::should_include_alert_role_on_field_errors() ) { |
| 236 | 236 | $error_body = self::get_error_body( $this->html ); |
| 237 | 237 | if ( is_string( $error_body ) && false === strpos( $error_body, 'role=' ) ) { |
| @@ -386,9 +386,9 @@ | ||
| 386 | 386 | if ( isset( $shortcode_atts['opt'] ) ) { |
| 387 | 387 | --$shortcode_atts['opt']; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - $field_class = $shortcode_atts['class'] ?? ''; | |
| 390 | + $field_class = isset( $shortcode_atts['class'] ) ? $shortcode_atts['class'] : ''; | |
| 391 | 391 | $this->field_obj->set_field_column( 'input_class', $field_class ); |
| 392 | 392 | |
| 393 | 393 | if ( isset( $shortcode_atts['class'] ) ) { |
| 394 | 394 | unset( $shortcode_atts['class'] ); |
| @@ -393,9 +393,9 @@ | ||
| 393 | 393 | if ( isset( $shortcode_atts['class'] ) ) { |
| 394 | 394 | unset( $shortcode_atts['class'] ); |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - $this->field_obj->set_aria_invalid_error( $shortcode_atts, $this->pass_args ); | |
| 397 | + $shortcode_atts['aria-invalid'] = isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ? 'true' : 'false'; | |
| 398 | 398 | |
| 399 | 399 | $this->field_obj->set_field_column( 'shortcodes', $shortcode_atts ); |
| 400 | 400 | |
| 401 | 401 | return $shortcode_atts; |
| @@ -429,12 +429,11 @@ | ||
| 429 | 429 | */ |
| 430 | 430 | private function add_field_div_classes() { |
| 431 | 431 | $classes = $this->get_field_div_classes(); |
| 432 | 432 | |
| 433 | - if ( in_array( $this->field_obj->get_field_column( 'type' ), array( 'html', 'summary' ), true ) && strpos( $this->html, '[error_class]' ) === false ) { | |
| 433 | + if ( $this->field_obj->get_field_column( 'type' ) === 'html' && strpos( $this->html, '[error_class]' ) === false ) { | |
| 434 | 434 | // there is no error_class shortcode for HTML fields |
| 435 | 435 | $this->html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . esc_attr( $classes ), $this->html ); |
| 436 | - return; | |
| 437 | 436 | } |
| 438 | 437 | |
| 439 | 438 | $this->html = str_replace( '[error_class]', esc_attr( $classes ), $this->html ); |
| 440 | 439 | } |
| @@ -523,13 +522,8 @@ | ||
| 523 | 522 | |
| 524 | 523 | // Add 'aria-required' attribute to the field if required. |
| 525 | 524 | if ( $is_radio && '1' === $field['required'] ) { |
| 526 | 525 | $attributes['aria-required'] = 'true'; |
| 527 | - } | |
| 528 | - | |
| 529 | - // Add 'aria-invalid' attribute to the group if there are errors. | |
| 530 | - if ( isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ) { | |
| 531 | - $attributes['aria-invalid'] = 'true'; | |
| 532 | 526 | } |
| 533 | 527 | |
| 534 | 528 | // Concatenate attributes into a string, and replace the role="group" in the HTML with the attributes string. |
| 535 | 529 | $html_attributes = FrmAppHelper::array_to_html_params( $attributes ); |