GravityView  1.19.4
The best, easiest way to display Gravity Forms entries on your website.
search-field-select.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Display the search SELECT input field
4  *
5  * @see class-search-widget.php
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  do_action('gravityview_log_debug', 'search-field-select.php - No choices for field' );
15  return;
16 }
17 
18 /**
19  * @filter `gravityview/extension/search/select_default` Define the text for the default option in a select (multi or single dropdown)
20  * @since 1.16.4
21  * @param string $default_option Default: `&mdash;` (—)
22  * @param string $field_type Field type: "select" or "multiselect"
23  */
24 $default_option = apply_filters('gravityview/extension/search/select_default', '&mdash;', 'select' );
25 
26 ?>
27 <div class="gv-search-box gv-search-field-select">
28  <?php if( ! gv_empty( $search_field['label'], false ) ) { ?>
29  <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"><?php echo esc_html( $search_field['label'] ); ?></label>
30  <?php } ?>
31  <p>
32  <select name="<?php echo esc_attr( $search_field['name'] ); ?>" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>">
33  <option value="" <?php gv_selected( '', $search_field['value'], true ); ?>><?php echo esc_html( $default_option ); ?></option>
34  <?php
35  foreach( $search_field['choices'] as $choice ) : ?>
36  <option value="<?php echo esc_attr( $choice['value'] ); ?>" <?php gv_selected( esc_attr( $choice['value'] ), esc_attr( $search_field['value'] ), true ); ?>><?php echo esc_html( $choice['text'] ); ?></option>
37  <?php endforeach; ?>
38  </select>
39  </p>
40 </div>
gv_empty($value, $zero_is_empty=true, $allow_string_booleans=true)
Is the value empty?
if(empty($search_field['choices'])) $default_option
gv_selected($value, $current, $echo=true, $type= 'selected')
Similar to the WordPress selected(), checked(), and disabled() functions, except it allows arrays to ...
static getInstance($passed_post=NULL)
$gravityview_view
Display the search SELECT input field.