PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.1.1
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.1.1
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
weforms / includes / fields / class-field-name.php

class-field-name.php in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.1.1, at includes/fields/class-field-name.php

162 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Text Field Class
5 */
6 class WeForms_Form_Field_Name extends WeForms_Field_Contract {
7
8 function __construct() {
9 $this->name = __( 'Name', 'weforms' );
10 $this->input_type = 'name_field';
11 $this->icon = 'user';
12 }
13
14 /**
15 * Render the text field
16 *
17 * @param array $field_settings
18 * @param integer $form_id
19 *
20 * @return void
21 */
22 public function render( $field_settings, $form_id ) {
23 ?>
24 <li <?php $this->print_list_attributes( $field_settings ); ?>>
25 <?php $this->print_label( $field_settings, $form_id ); ?>
26
27 <div class="wpuf-fields">
28 <div class="wpuf-name-field-wrap format-<?php echo $field_settings['format']; ?>">
29 <div class="wpuf-name-field-first-name">
30 <input
31 name="<?php echo $field_settings['name'] ?>[first]"
32 type="text"
33 placeholder="<?php echo esc_attr( $field_settings['first_name']['placeholder'] ); ?>"
34 value="<?php echo esc_attr( $field_settings['first_name']['default'] ); ?>"
35 size="40"
36 data-required="<?php echo $field_settings['required'] ?>"
37 data-type="text"
38 class="textfield wpuf_<?php echo $field_settings['name']; ?>_<?php echo $form_id; ?>"
39 autocomplete="given-name"
40 >
41
42 <?php if ( ! $field_settings['hide_subs'] ) : ?>
43 <label class="wpuf-form-sub-label"><?php _e( 'First', 'weforms' ); ?></label>
44 <?php endif; ?>
45 </div>
46
47 <?php if ( $field_settings['format'] != 'first-last' ) : ?>
48 <div class="wpuf-name-field-middle-name">
49 <input
50 name="<?php echo $field_settings['name'] ?>[middle]"
51 type="text" class="textfield"
52 placeholder="<?php echo esc_attr( $field_settings['middle_name']['placeholder'] ); ?>"
53 value="<?php echo esc_attr( $field_settings['middle_name']['default'] ); ?>"
54 size="40"
55 autocomplete="additional-name"
56 >
57
58 <?php if ( ! $field_settings['hide_subs'] ) : ?>
59 <label class="wpuf-form-sub-label"><?php _e( 'Middle', 'weforms' ); ?></label>
60 <?php endif; ?>
61 </div>
62 <?php else: ?>
63 <input type="hidden" name="<?php echo $field_settings['name'] ?>[middle]" value="">
64 <?php endif; ?>
65
66 <div class="wpuf-name-field-last-name">
67 <input
68 name="<?php echo $field_settings['name'] ?>[last]"
69 type="text" class="textfield"
70 placeholder="<?php echo esc_attr( $field_settings['last_name']['placeholder'] ); ?>"
71 value="<?php echo esc_attr( $field_settings['last_name']['default'] ); ?>"
72 size="40"
73 autocomplete="family-name"
74 >
75 <?php if ( ! $field_settings['hide_subs'] ) : ?>
76 <label class="wpuf-form-sub-label"><?php _e( 'Last', 'weforms' ); ?></label>
77 <?php endif; ?>
78 </div>
79 </div>
80 <?php $this->help_text( $field_settings ); ?>
81 </div>
82 </li>
83 <?php
84 }
85
86 /**
87 * Get field options setting
88 *
89 * @return array
90 */
91 public function get_options_settings() {
92 $default_options = $this->get_default_option_settings();
93
94 $name_settings = array(
95 array(
96 'name' => 'format',
97 'title' => __( 'Format', 'weforms' ),
98 'type' => 'radio',
99 'options' => array(
100 'first-last' => __( 'First and Last name', 'weforms' ),
101 'first-middle-last' => __( 'First, Middle and Last name', 'weforms' )
102 ),
103 'selected' => 'first-last',
104 'section' => 'advanced',
105 'priority' => 20,
106 'help_text' => __( 'Select format to use for the name field', 'weforms' ),
107 ),
108 array(
109 'name' => 'sub-labels',
110 'title' => __( 'Label', 'weforms' ),
111 'type' => 'name',
112 'section' => 'advanced',
113 'priority' => 21,
114 'help_text' => __( 'Select format to use for the name field', 'weforms' ),
115 ),
116 array(
117 'name' => 'hide_subs',
118 'title' => '',
119 'type' => 'checkbox',
120 'is_single_opt' => true,
121 'options' => array(
122 'true' => __( 'Hide Sub Labels', 'weforms' )
123 ),
124 'section' => 'advanced',
125 'priority' => 23,
126 'help_text' => '',
127 ),
128 );
129
130 return array_merge( $default_options, $name_settings );
131 }
132
133 /**
134 * Get the field props
135 *
136 * @return array
137 */
138 public function get_field_props() {
139 $defaults = $this->default_attributes();
140 $props = array(
141 'format' => 'first-last',
142 'first_name' => array(
143 'placeholder' => '',
144 'default' => '',
145 'sub' => __( 'First', 'weforms' )
146 ),
147 'middle_name' => array(
148 'placeholder' => '',
149 'default' => '',
150 'sub' => __( 'Middle', 'weforms' )
151 ),
152 'last_name' => array(
153 'placeholder' => '',
154 'default' => '',
155 'sub' => __( 'Last', 'weforms' )
156 ),
157 'hide_subs' => false,
158 );
159
160 return array_merge( $defaults, $props );
161 }
162 }