PluginProbe
WP Directory Kit / 1.5.9
WP Directory Kit v1.5.9
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
wpdirectorykit / application / views / fields_edit / DROPDOWNMULTIPLE.php

DROPDOWNMULTIPLE.php in WP Directory Kit 1.5.9, at application/views/fields_edit/DROPDOWNMULTIPLE.php

127 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 * The template for Edit field DROPDOWN.
4 *
5 * This is the template that field layout for edit form
6 *
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12 ?>
13 <?php
14
15 //wmvc_dump($field);
16
17 if(isset($field->field))
18 {
19 $field_id = $field->field;
20 }
21 else
22 {
23 $field_id = 'field_'.$field->idfield;
24 }
25
26 if(!isset($field->hint))$field->hint = '';
27
28 $field_label = $field->field_label;
29
30 if(!isset($field->hint))$field->hint = '';
31 if(!isset($field->class))$field->class = '';
32 if(!isset($field->columns_number))$field->columns_number = '';
33 if(!isset($field->prefix))$field->prefix = '';
34 if(!isset($field->suffix))$field->suffix = '';
35
36 $required = '';
37 if(isset($field->is_required) && $field->is_required == 1)
38 $required = '*';
39
40
41 if(isset($field->rules) && strpos($field->rules, 'required') !== FALSE)
42 $required = '*';
43
44 if(!empty($field->values) && is_array($field->values)){
45 $values = $field->values;
46 } else {
47 $values = array();
48 if(!empty($field->values_list)){
49 $values = explode(',', $field->values_list);
50 $values = array_combine($values, $values);
51 if(isset($values[''])) {
52 unset($values['']);
53 }
54 }
55 }
56 $empty_value = __('Selecte', 'wpdirectorykit').' '.$field_label;
57 $button_suffix = '';
58
59 //var_dump($values);
60 wp_enqueue_script('select2-select2');
61 wp_enqueue_script('wdk-select2');
62 wp_enqueue_style('select2-select2');
63
64
65 $post_values = wmvc_show_data($field_id, $db_data, '');
66 $post_values = explode(',', $post_values);
67 ?>
68
69 <div class="wdk-field-<?php echo esc_attr($field_id);?> wdk-field-edit <?php echo esc_attr($field->field_type); ?> wdk-col-<?php echo esc_attr($field->columns_number); ?> <?php echo esc_attr($field->class); ?> <?php echo esc_attr($field->class); ?> <?php if(!empty($form) && method_exists($form, 'hasError') && $form->hasError($field_id)):?> field-error <?php endif;?>">
70 <label for="<?php echo esc_attr($field_id); ?>"><?php echo esc_html($field_label).esc_html($required); ?></label>
71 <div class="wdk-field-container">
72 <?php
73 echo wp_kses(
74 wdk_select_option_multiple(
75 $field_id.'_select2',
76 $values,
77 $post_values,
78 "id='".$field_id."_select2' class='select_multi' data-maxselectlimit='20' data-placeholder='".esc_attr($empty_value)."'"
79 ),
80 [
81 'select' => [
82 'id' => true,
83 'class' => true,
84 'data-maxselectlimit' => true,
85 'data-placeholder' => true,
86 'multiple' => true,
87 'name' => true,
88 ],
89 'option' => [
90 'value' => true,
91 'selected' => true,
92 ],
93 ]
94 );
95 ?>
96
97 <span class="suffix"><?php
98 // Dynamic field values are registered in the translation catalog separately.
99 // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
100 echo esc_html__($field->prefix, 'wpdirectorykit');
101 if(!empty($field->prefix) && !empty($field->suffix)) echo ' / ';
102 // Dynamic field values are registered in the translation catalog separately.
103 // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
104 echo esc_html__($field->suffix, 'wpdirectorykit');
105 ?></span>
106 <?php if(!empty($field->hint)):?>
107 <p class="wdk-hint">
108 <?php echo esc_html($field->hint); ?>
109 </p>
110 <?php endif;?>
111 <?php if(!empty($form) && method_exists($form, 'hasError') && $form->getError($field_id)):?>
112 <p class="wdk-hint wdk-error">
113 <?php echo wp_kses_post($form->getError($field_id)); ?>
114 </p>
115 <?php endif;?>
116 <input type="hidden" name="<?php echo esc_attr($field_id);?>" id="<?php echo esc_attr($field_id);?>" value="<?php echo esc_attr(wmvc_show_data($field_id, $db_data, '')); ?>"/>
117 </div>
118 <script>
119
120 jQuery(document).ready(function ($) {
121 $('#<?php echo esc_js($field_id);?>_select2').on('change', function(){
122 $("#<?php echo esc_js($field_id);?>").val(jQuery(this).val().join(','));
123 })
124 });
125
126 </script>
127 </div>