PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / classes / views / frm-fields / front-end / address-field / address-field.php

address-field.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More trunk, at classes/views/frm-fields/front-end/address-field/address-field.php

113 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Frontend template for address field
4 *
5 * @package Formidable
6 *
7 * @since 6.34
8 *
9 * @var array $args Data passed to this view. See FrmFieldCombo::load_field_output().
10 * @var array $shortcode_atts Shortcode attributes.
11 * @var array $sub_fields Sub fields array.
12 * @var string $html_id HTML ID.
13 * @var string $field_name Field Name.
14 * @var array $errors Field errors.
15 * @var bool $remove_names Remove field name or not.
16 * @var FrmFieldCombo $this Field type object.
17 */
18
19 if ( ! defined( 'ABSPATH' ) ) {
20 die( 'You are not allowed to call this page directly.' );
21 }
22
23 $field = $args['field'];
24 $field_id = $field['id'];
25 $field_label = $field['name'];
26 $field_value = $field['value'];
27 $sub_fields = $args['sub_fields'];
28 $html_id = $args['html_id'];
29 $field_name = $args['field_name'];
30 $errors = $args['errors'];
31 $atts = $args['shortcode_atts'] ?? array();
32 $inputs_attrs = $this->get_inputs_container_attrs();
33 ?>
34 <fieldset aria-labelledby="<?php echo esc_attr( $html_id ); ?>_label">
35 <legend class="frm_screen_reader frm_hidden">
36 <?php echo esc_html( $field_label ); ?>
37 </legend>
38
39 <div <?php FrmAppHelper::array_to_html_params( $inputs_attrs, true ); ?>>
40 <?php
41 foreach ( $sub_fields as $key => $sub_field ) {
42 $name = $key;
43 $sub_field['name'] = $name;
44 ?>
45 <div
46 id="frm_field_<?php echo esc_attr( $field_id . '-' . $name ); ?>_container"
47 class="frm_form_field form-field frm_form_subfield-<?php echo esc_attr( $name ); ?> <?php echo esc_attr( $sub_field['wrapper_classes'] ); ?><?php
48 if ( isset( $errors ) ) {
49 FrmComboFieldsController::maybe_add_error_class( compact( 'field', 'key', 'errors', 'atts' ) );
50 }
51 ?>"
52 data-sub-field-name="<?php echo esc_attr( $name ); ?>"
53 >
54 <label for="<?php echo esc_attr( $html_id . '_' . $name ); ?>" class="frm_screen_reader frm_hidden">
55 <?php echo esc_html( ! empty( $field[ $name . '_desc' ] ) ? $field[ $name . '_desc' ] : $field['name'] ); ?>
56 </label>
57 <?php if ( 'select' === $sub_field['type'] ) { ?>
58 <select name="<?php echo esc_attr( $field_name ); ?>[<?php echo esc_attr( $name ); ?>]" id="<?php echo esc_attr( $html_id . '_' . $name ); ?>" <?php FrmComboFieldsController::add_atts_to_input( compact( 'field', 'sub_field', 'key' ) ); ?>>
59 <option value="" class="<?php echo esc_attr( ! empty( $field['placeholder'][ $name ] ) ? 'frm-select-placeholder' : '' ); ?>">
60 <?php echo esc_html( FrmComboFieldsController::get_dropdown_label( compact( 'field', 'key', 'sub_field' ) ) ); ?>
61 </option>
62 <?php
63 foreach ( $sub_field['options'] as $option ) {
64 $selected = isset( $field['value'][ $name ] ) && (string) $field['value'][ $name ] === (string) $option;
65 $params = array( 'value' => $option );
66
67 if ( 'address' === $field['type'] && 'country' === $name ) {
68 $code = FrmAddressesController::get_country_code( $option );
69
70 if ( $code ) {
71 $params['data-code'] = $code;
72 }
73 }
74
75 FrmHtmlHelper::echo_dropdown_option( $option, $selected, $params );
76 }
77 ?>
78 </select>
79 <?php } else { ?>
80 <input type="<?php echo esc_attr( $sub_field['type'] ); ?>" id="<?php echo esc_attr( $html_id . '_' . $name ); ?>" value="<?php echo esc_attr( $field['value'][ $name ] ?? '' ); ?>" <?php
81 if ( empty( $remove_names ) ) {
82 echo 'name="' . esc_attr( $field_name ) . '[' . esc_attr( $name ) . ']" ';
83 }
84 FrmComboFieldsController::add_atts_to_input( compact( 'field', 'sub_field', 'key' ) );
85 ?> />
86 <?php
87 }//end if
88 ?>
89
90 <?php
91 if ( $sub_field['label'] ) {
92 FrmComboFieldsController::include_sub_label(
93 array(
94 'field' => $field,
95 'option_name' => $name . '_desc',
96 )
97 );
98 }
99
100 $temp_id = ! empty( $atts['field_id'] ) ? $atts['field_id'] : $field['id'];
101
102 // Don't show individual field errors when there is a combo field error
103 if ( $errors && isset( $errors[ 'field' . $temp_id . '-' . $name ] ) && ! isset( $errors[ 'field' . $field['id'] ] ) ) {
104 ?>
105 <div class="frm_error" role="alert"><?php echo esc_html( $errors[ 'field' . $temp_id . '-' . $name ] ); ?></div>
106 <?php } ?>
107 </div>
108 <?php
109 }//end foreach
110 ?>
111 </div>
112 </fieldset>
113