Use dropdown in views exposed filter on text fields with node->title? I followed this link to transform my exposed filter from textbox to  dropdown list.

Use dropdown in views exposed filter on text fields with entity not node? 

I make it work with a custom textfield.

I have problem to use the module with node title.

My code till now is:

&lt;?php

function views_dropdown_form_views_exposed_form_alter(&amp;$form, &amp;$form_state) {
global $user;

// Only alter forms with the necessary field
if (isset($form['title'])) {

// Build a query to get all node ids having the specified field
$query = new EntityFieldQuery();

$results = $query-&gt;entityCondition('entity_type', 'node')
                  -&gt;entityCondition('bundle', 'rapporto_di_lavoro')
                  -&gt;propertyCondition('uid', $user-&gt;uid)
                  -&gt;propertyCondition('title', 'NULL', '!=')
                  -&gt;execute();


// Attach the field values to the nodes
$ids = array_keys($results['node']);
print_r($ids);
print('&lt;br&gt;');
// Add a default so the filter is optional
$options = array('' =&gt; '&lt;select&gt;');

// Buld the options array based on the query results, overwriting duplicate entries
$query = db_select('node', 'n')
            -&gt;fields('n', array('title'))     
            -&gt;condition('n.nid', $ids, 'IN');
$options = $query-&gt;execute()-&gt;fetchAll();

$op = json_decode(json_encode($options), true);
print_r($op);
print('&lt;br&gt;');


// Attach the field values to the nodes
//$nodes = $results['node'];
//field_attach_load('node', $nodes, FIELD_LOAD_CURRENT, array('field_id' =&gt; $field_id));
// Buld the options array based on the query results, overwriting duplicate entries
//foreach($nodes as $nid =&gt; $node) {
  //$value = $node-&gt;field_cognome_l['und'][0]['value'];
  //$options2[$value] = $value; }



//Alter the field
$form['title']['#type'] = 'select';
$form['title']['#options'] = $op;
$form['title']['#size'] = 1;
}
}


I feel close to solution but I miss something.

On the picture I print four arrays.



Only the 4th was working when I tested the module with a custom field, 

so probably I need to transform the 3rd array into the 4th.
I solved the problem, here the code:

&lt;?php

function views_dropdown_form_views_exposed_form_alter(&amp;$form, &amp;$form_state) {
global $user;

// Only alter forms with the necessary field
if (isset($form['title'])) {

// Build a query to get all node ids having the specified field
$query = new EntityFieldQuery();

$results = $query-&gt;entityCondition('entity_type', 'node')
                  -&gt;entityCondition('bundle', 'rapporto_di_lavoro')
                  -&gt;propertyCondition('uid', $user-&gt;uid)
                  -&gt;propertyCondition('title', 'NULL', '!=')
                  -&gt;execute();


// Attach the field values to the nodes
$ids = array_keys($results['node']);
// Add a default so the filter is optional
$options = array('' =&gt; '&lt;select&gt;');

// // Buld the options array based on the query results, overwriting duplicate entries
$query = db_select('node', 'n')
            -&gt;fields('n', array('title'))     
            -&gt;condition('n.nid', $ids, 'IN');

$results = $query-&gt;execute()-&gt;fetchAll();

foreach($results as $id =&gt; $node) {
  $value = $node-&gt;title;
  $options[$value] = $value;
}


// // Alter the field
$form['title']['#type'] = 'select';
$form['title']['#options'] = $options;
$form['title']['#size'] = 1;
}}




I hope could help someone :)