Use select fields as posts Drop-Down

I was creating an Module for my client, and realized there is no drop-down fields reference for post types, only the suggest fields to find posts / pages. But the client only got some “events” and a drop-down would be the better solution. Here are the snippets for the module.

Function to get an array of the posttype “pec-events”:
function wn_get_events_list() {
$args = array(
‘post_type’ => ‘pec-events’,
‘numberposts’ => -1,
‘post_status’ => ‘publish’
$events = get_posts($args);

		foreach ( $events as $e ) {
		    	$wn_events_array[$e->ID] = $e->post_title;

	  	return $wn_events_array;

Call the function in the select field
‘wnbutton_id’ => array(
‘type’ => ‘select’,
‘label’ => __( ‘Welches Event’, ‘fl-builder’ ),
‘options’ => wn_get_events_list(),