PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.2.8.2
Pods – Custom Content Types and Fields v3.2.8.2
trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / ui / fields / select.php
pods / ui / fields Last commit date
_comment.php 2 years ago _db.php 2 years ago _hidden.php 2 years ago _label.php 2 years ago _row.php 2 years ago attachment.php 1 year ago checkbox.php 1 year ago cleditor.php 2 years ago codemirror.php 2 years ago color.php 2 years ago currency.php 2 years ago date.php 2 years ago datetime.php 2 years ago email.php 2 years ago link.php 1 year ago number.php 2 years ago oembed.php 1 year ago password.php 2 years ago phone.php 2 years ago radio.php 2 years ago select.php 2 years ago slider.php 1 year ago slug.php 2 years ago text.php 2 years ago textarea.php 2 years ago time.php 2 years ago tinymce.php 2 years ago website.php 2 years ago
select.php
110 lines
1 <?php
2 // Don't load directly.
3 if ( ! defined( 'ABSPATH' ) ) {
4 die( '-1' );
5 }
6
7 $attributes = array();
8 $attributes['tabindex'] = 2;
9
10 $pick_limit = (int) pods_var( $form_field_type . '_limit', $options, 0 );
11 $multiple = false;
12
13 if ( 'multi' == pods_var( $form_field_type . '_format_type', $options ) && 1 != $pick_limit ) {
14 $name .= '[]';
15 $attributes['multiple'] = 'multiple';
16 $multiple = true;
17 }
18
19 if ( ! is_array( $options['data'] ) && false !== $options['data'] && 0 < strlen( $options['data'] ) ) {
20 $options['data'] = implode( ',', $options['data'] );
21 } else {
22 $options['data'] = (array) pods_var_raw( 'data', $options, array(), null, true );
23 }
24
25 $attributes = PodsForm::merge_attributes( $attributes, $name, $form_field_type, $options );
26
27 if ( pods_var( 'readonly', $options, false ) ) {
28 $attributes['readonly'] = 'READONLY';
29
30 $attributes['class'] .= ' pods-form-ui-read-only';
31 }
32
33 $selection_made = false;
34 ?>
35 <select<?php PodsForm::attributes( $attributes, $name, $form_field_type, $options ); ?>>
36 <?php
37 foreach ( $options['data'] as $option_value => $option_label ) {
38 if ( is_array( $option_label ) && isset( $option_label['label'] ) ) {
39 $option_label = $option_label['label'];
40 }
41
42 if ( is_array( $option_label ) ) {
43 ?>
44 <optgroup label="<?php echo esc_attr( $option_value ); ?>">
45 <?php
46 foreach ( $option_label as $sub_option_value => $sub_option_label ) {
47 if ( is_array( $sub_option_label ) ) {
48 if ( isset( $sub_option_label['label'] ) ) {
49 $sub_option_label = $sub_option_label['label'];
50 } else {
51 $sub_option_label = $sub_option_value;
52 }
53 }
54
55 $sub_option_label = (string) $sub_option_label;
56
57 $selected = '';
58 $options['selected'] = '';
59
60 if ( ! $selection_made && ( ( ! is_array( $value ) && (string) $sub_option_value === (string) $value ) || ( is_array( $value ) && ( in_array( $sub_option_value, $value ) || in_array( (string) $sub_option_value, $value ) ) ) ) ) {
61 $selected = ' SELECTED';
62 $options['selected'] = 'selected';
63
64 if ( ! $multiple ) {
65 $selection_made = true;
66 }
67 }
68
69 if ( is_array( $sub_option_value ) ) {
70 ?>
71 <option<?php PodsForm::attributes( $sub_option_value, $name, $form_field_type . '_option', $options ); ?>><?php echo esc_html( $sub_option_label ); ?></option>
72 <?php
73 } else {
74 ?>
75 <option value="<?php echo esc_attr( $sub_option_value ); ?>"<?php echo $selected; ?>><?php echo esc_html( $sub_option_label ); ?></option>
76 <?php
77 }
78 }//end foreach
79 ?>
80 </optgroup>
81 <?php
82 } else {
83 $option_label = (string) $option_label;
84
85 $selected = '';
86 $options['selected'] = '';
87
88 if ( ! $selection_made && ( ( ! is_array( $value ) && (string) $option_value === (string) $value ) || ( is_array( $value ) && ( in_array( $option_value, $value ) || in_array( (string) $option_value, $value ) ) ) ) ) {
89 $selected = ' SELECTED';
90 $options['selected'] = 'selected';
91
92 if ( ! $multiple ) {
93 $selection_made = true;
94 }
95 }
96
97 if ( is_array( $option_value ) ) {
98 ?>
99 <option<?php PodsForm::attributes( $option_value, $name, $form_field_type . '_option', $options ); ?>><?php echo esc_html( $option_label ); ?></option>
100 <?php
101 } else {
102 ?>
103 <option value="<?php echo esc_attr( $option_value ); ?>"<?php echo $selected; ?>><?php echo esc_html( $option_label ); ?></option>
104 <?php
105 }
106 }//end if
107 }//end foreach
108 ?>
109 </select>
110