| @@ -73,8 +73,24 @@ | ||
| 73 | 73 | ), |
| 74 | 74 | $defaults |
| 75 | 75 | ); |
| 76 | 76 | } |
| 77 | + }//end foreach | |
| 78 | + } | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * Set the aria-invalid attribute for subfields. | |
| 82 | + * | |
| 83 | + * @since 6.16.3 | |
| 84 | + * | |
| 85 | + * @param array $shortcode_atts | |
| 86 | + * @param array $args | |
| 87 | + * | |
| 88 | + * @return void | |
| 89 | + */ | |
| 90 | + public function set_aria_invalid_error( &$shortcode_atts, $args ) { | |
| 91 | + foreach ( $this->get_sub_fields() as $sub_field ) { | |
| 92 | + $shortcode_atts[ 'aria-invalid-' . $sub_field['name'] ] = isset( $args['errors'][ 'field' . $this->field_id . '-' . $sub_field['name'] ] ) ? 'true' : 'false'; | |
| 77 | 93 | } |
| 78 | 94 | } |
| 79 | 95 | |
| 80 | 96 | /** |
| @@ -112,9 +128,10 @@ | ||
| 112 | 128 | continue; |
| 113 | 129 | } |
| 114 | 130 | |
| 115 | 131 | foreach ( $sub_field['options'] as $option ) { |
| 116 | - if ( 'default_value' === $option ) { // We parse default value from field column. | |
| 132 | + if ( 'default_value' === $option ) { | |
| 133 | + // We parse default value from field column. | |
| 117 | 134 | continue; |
| 118 | 135 | } |
| 119 | 136 | |
| 120 | 137 | if ( is_string( $option ) ) { |
| @@ -181,9 +198,10 @@ | ||
| 181 | 198 | |
| 182 | 199 | return $default_value; |
| 183 | 200 | } |
| 184 | 201 | |
| 185 | - return json_decode( $default_value, true ); // We store default value as JSON string in db. | |
| 202 | + // We store default value as JSON string in db. | |
| 203 | + return json_decode( $default_value, true ); | |
| 186 | 204 | } |
| 187 | 205 | |
| 188 | 206 | /** |
| 189 | 207 | * Gets labels for built-in options of fields or sub fields. |
| @@ -206,9 +224,10 @@ | ||
| 206 | 224 | protected function field_settings_for_type() { |
| 207 | 225 | $settings = array( |
| 208 | 226 | 'description' => false, |
| 209 | 227 | 'default' => false, |
| 210 | - 'clear_on_focus' => false, // Don't use the regular placeholder option. | |
| 228 | + // Don't use the regular placeholder option. | |
| 229 | + 'clear_on_focus' => false, | |
| 211 | 230 | 'logic' => true, |
| 212 | 231 | 'visibility' => true, |
| 213 | 232 | ); |
| 214 | 233 | |
| @@ -374,10 +393,14 @@ | ||
| 374 | 393 | if ( $classes ) { |
| 375 | 394 | $field['input_class'] = esc_attr( $classes ); |
| 376 | 395 | } |
| 377 | 396 | |
| 378 | - $field['default_value'] = ''; // fake it to avoid printing frm-val attribute. | |
| 397 | + // Fake it to avoid printing frm-val attribute. | |
| 398 | + $field['default_value'] = ''; | |
| 379 | 399 | |
| 400 | + if ( ! empty( $sub_field['name'] ) ) { | |
| 401 | + $field['subfield_name'] = $sub_field['name']; | |
| 402 | + } | |
| 380 | 403 | do_action( 'frm_field_input_html', $field ); |
| 381 | 404 | |
| 382 | 405 | // Print custom attributes. |
| 383 | 406 | if ( ! empty( $sub_field['atts'] ) && is_array( $sub_field['atts'] ) ) { |
| @@ -441,9 +464,8 @@ | ||
| 441 | 464 | return $headings; |
| 442 | 465 | } |
| 443 | 466 | |
| 444 | 467 | /** |
| 445 | - * | |
| 446 | 468 | * Get a list of all field settings that should be translated |
| 447 | 469 | * on a multilingual site. |
| 448 | 470 | * |
| 449 | 471 | * @since 3.06.01 |