Display values from exposed field in Views as a Dropdown
There is a small mistake in the code

$value = $node-&gt;{$field_id}['und'][0]['locality'];


should be 

$value = $term-&gt;{$field_id}['und'][0]['locality'];