diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php index 1ad87268b9..59ff0dfb2f 100644 --- a/classes/helpers/FrmAppHelper.php +++ b/classes/helpers/FrmAppHelper.php @@ -1691,7 +1691,7 @@ public static function maybe_autocomplete_pages_options( $args ) { $pages_count = wp_count_posts( $args['post_type'] ); - if ( $pages_count->publish <= 50 ) { + if ( ! isset( $pages_count->publish ) || $pages_count->publish <= 50 ) { self::wp_pages_dropdown( $args ); return; } @@ -1716,6 +1716,101 @@ class="frm_autocomplete_value_input" false, + 'placeholder' => ' ', + 'name' => '', + 'id' => '', + 'selected' => '', + 'source' => array(), + 'dropdown_limit' => 50, + 'autocomplete_placeholder' => __( 'Select an option', 'formidable' ), + 'value_key' => 'value', + 'label_key' => 'label', + ); + + $args = wp_parse_args( $args, $defaults ); + + $html_attrs = array(); + if ( ! empty( $args['name'] ) ) { + $html_attrs['name'] = $args['name']; + } + + if ( ! empty( $args['id'] ) ) { + $html_attrs['id'] = $args['id']; + } + + if ( count( $args['source'] ) <= $args['dropdown_limit'] ) { + ?> + + $source ) { + $value_label = self::get_dropdown_value_and_label_from_option( $source, $key, $args ); + + if ( $value_label['value'] === $args['selected'] ) { + $autocomplete_value = $value_label['label']; + } + + $options[] = $value_label; + } + + $html_attrs['type'] = 'hidden'; + $html_attrs['class'] = 'frm_autocomplete_value_input'; + $html_attrs['value'] = $args['selected']; + ?> + + /> +