GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
search-field-multiselect.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Display the search MULTISELECT input field
4  *
5  * @file class-search-widget.php See for usage
6  */
7 
9 $view_id = $gravityview_view->getViewId();
11 
12 // Make sure that there are choices to display
13 if( empty( $search_field['choices'] ) ) {
14  gravityview()->log->debug( 'search-field-multiselect.php - No choices for field' );
15  return;
16 }
17 
18 $gf_field = GFAPI::get_field( $gravityview_view->getForm(), $search_field['key'] );
19 $placeholder = \GV\Utils::get( $gf_field, 'placeholder', '' );
20 
21 /**
22  * @filter `gravityview/extension/search/select_default` Define the text for the default option in a select (multi or single dropdown)
23  * @since 1.16.4
24  * @param string $default_option Default: `&mdash;` (—)
25  * @param string $field_type Field type: "select" or "multiselect"
26  */
27 $default_option = apply_filters('gravityview/extension/search/select_default', ( '' === $placeholder ? '&mdash;' : $placeholder ), 'multiselect' );
28 
29 ?>
30 <div class="gv-search-box gv-search-field-multiselect">
31  <?php if( ! gv_empty( $search_field['label'], false, false ) ) { ?>
32  <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"><?php echo esc_html( $search_field['label'] ); ?></label>
33  <?php } ?>
34  <p>
35  <select name="<?php echo esc_attr( $search_field['name'] ); ?>[]" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" multiple>
36  <option value="" <?php gv_selected( '', $search_field['value'], true ); ?>><?php echo esc_html( $default_option ); ?></option>
37  <?php
38  foreach( $search_field['choices'] as $choice ) : ?>
39  <option value="<?php echo esc_attr( $choice['value'] ); ?>" <?php gv_selected( $choice['value'], $search_field['value'], true ); ?>><?php echo esc_html( $choice['text'] ); ?></option>
40  <?php endforeach; ?>
41  </select>
42  </p>
43 </div>
static getInstance( $passed_post=NULL)
if(empty( $search_field['choices'])) $gf_field
static get( $array, $key, $default=null)
Grab a value from an array or an object or default.
gravityview()
The main GravityView wrapper function.
gv_empty( $value, $zero_is_empty=true, $allow_string_booleans=true)
Is the value empty?
gv_selected( $value, $current, $echo=true, $type='selected')
Similar to the WordPress selected(), checked(), and disabled() functions, except it allows arrays to ...