diff --git a/term_reference_filter_by_views.module b/term_reference_filter_by_views.module
index f7eff46..0165487 100755
--- a/term_reference_filter_by_views.module
+++ b/term_reference_filter_by_views.module
@@ -20,7 +20,7 @@ function term_reference_filter_by_views_menu() {
 function term_reference_filter_by_views_field_widget_form_alter(&$element, &$form_state, $context) {
   // Add a css class to widget form elements for all fields of type mytype.
   if ($context['field']['type'] == 'taxonomy_term_reference') {
-    if (!empty($context['instance']['view'])) {
+    if (!empty($context['instance']['view']['view_name'])) {
       if (isset($element['#type']) && ($element['#type'] == 'select' || $element['#type'] == 'radios' || $element['#type'] == 'checkboxes')) {
         $allowed = _get_referencable_terms_from_view($context['field'], $context['instance'], NULL, 0, NULL, FALSE);
         if (!empty($allowed)) {
