Contact Form 7 Plugin Select Field

Example:

<?php
class CF7_Fields_Widget extends WP_Widget {
function __construct() {
// Instantiate the parent object
$widget_ops = array(
'classname' => 'widget_title_fields_entries',
'description' => esc_attr__('CF7 Field Widget - Created by deshisoft', 'eye-theme')
);
$control_ops = array(
'width' => 275
);
parent::__construct( false, 'CF7 Field Widget', $widget_ops, $control_ops );
}
function widget( $args, $instance ) {
extract( $args );
// Widget output
$title = apply_filters('widget_title', $instance['title']);
// Contact Form 7
$wpcf7 = apply_filters('widget_wpcf7', $instance['wpcf7']);
echo $before_widget;
echo '<div style="border:1px solid #ddd; background:#f6f6f6;padding:15px;">';
echo esc_attr($title);
echo do_shortcode($wpcf7);
echo '</div>';
echo $after_widget;
}
function update( $new_instance, $old_instance ) {
// Save widget options
$instance = array();
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['wpcf7'] = strip_tags( $new_instance['wpcf7'] );
return $instance;
}
function form( $instance ) {
// Output admin widget options form
$title = $instance['title'];
$wpcf7 = esc_attr($instance['wpcf7']); ?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
<!-- Contact Form7 -->
<?php
$option_query = new WP_Query(array(
'orderby' => 'name',
'order' => 'ASC',
'post_type' => 'wpcf7_contact_form',
'posts_per_page' => -1
));
?>
<p><label><?php _e('Leave a Message Form: <br/><em style="font-size:12px; color:#0073aa;">Make sure the <a target="_blank" href="https://wordpress.org/plugins/contact-form-7/">contact form 7</a> plugin is install.</em><br/>'); ?></label><br/>
<select id="<?php echo $this->get_field_id('wpcf7'); ?>" name="<?php echo $this->get_field_name('wpcf7'); ?>" >
<option value="" <?php echo ($instance['wpcf7'] === '' ? ' selected="selected"' : ''); ?>>Select Form</option>
<?php $forms = array();
if ($option_query->have_posts()) :
while ($option_query->have_posts() ) : $option_query->the_post(); ?>
<option value='

Error: Contact form not found.

' <?php echo ($instance['wpcf7'] === '

Error: Contact form not found.

' ? ' selected="selected"' : ''); ?>><?php echo $forms[get_the_ID()] = get_the_title(); ?></option> <?php endwhile; endif; wp_reset_query(); ?> </select></p> <?php } } function cf7_field_register_widgets() { register_widget( 'CF7_Fields_Widget' ); } add_action( 'widgets_init', 'cf7_field_register_widgets' ); ?>

Theme Folder -> function.php
Add this line:

require get_template_directory() . '/inc/contact_form7_widget.php';   // inc folder name depend on your theme.

Download Contact Form 7 Widget Field