PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 1.1.0
JetFormBuilder — Dynamic Blocks Form Builder v1.1.0
3.6.6.1 3.6.6 3.6.5.4 3.6.5.3 3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 134 releases
jetformbuilder / templates / fields / select-field.php

select-field.php in JetFormBuilder — Dynamic Blocks Form Builder 1.1.0, at templates/fields/select-field.php

66 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * input[type="hidden"] template
4 */
5
6 $this->add_attribute( 'required', $this->block_type->get_required_val( $args ) );
7 $this->add_attribute( 'name', $this->block_type->get_field_name( $args['name'] ) );
8 $this->add_attribute( 'data-field-name', $args['name'] );
9 $this->add_attribute( 'id', $this->block_type->get_field_id( $args ) );
10
11 if ( ! empty( $args['switch_on_change'] ) ) {
12 $this->add_attribute( 'data-switch', 1 );
13 }
14
15 $placeholder = isset( $args['placeholder'] ) ? $args['placeholder'] : false;
16 $default = isset( $args['default'] ) ? $args['default'] : false;
17
18 $this->add_attribute( 'data-default-val', $default );
19
20 ?>
21 <div class="jet-form-builder__field-wrap">
22 <select class="jet-form-builder__field select-field"<?php $this->render_attributes_string(); ?>><?php
23
24 if ( $placeholder ) {
25 $selected_placeholder = '';
26
27 if ( ! $default ){
28 $selected_placeholder = 'selected';
29 }
30
31 printf( '<option value="" %1$s>%2$s</option>', $selected_placeholder, $placeholder );
32 }
33
34 if ( ! empty( $args['field_options'] ) ) {
35
36 foreach ( $args['field_options'] as $value => $option ) {
37
38 $selected = '';
39 $calc = '';
40
41
42 if ( is_array( $option ) ) {
43 $val = isset( $option['value'] ) ? $option['value'] : $value;
44 $label = isset( $option['label'] ) ? $option['label'] : $val;
45 } else {
46 $val = $value;
47 $label = $option;
48 }
49
50 if ( $default ) {
51 $selected = selected( $default, $val, false );
52 }
53
54 if ( is_array( $option ) && isset( $option['calculate'] ) ) {
55 $calc = ' data-calculate="' . $option['calculate'] . '"';
56 }
57
58 printf( '<option value="%1$s" %3$s%4$s>%2$s</option>', $val, $label, $selected, $calc );
59
60 }
61
62 }
63
64 ?></select>
65 <?php echo $this->maybe_render_error( $args ); ?>
66 </div>