Notice: Trying to get property of non-object
$form_state['view'] is not defined for all the forms, and it is not a value set by Drupal core modules. Before to access $form_state['view']-&gt;name you should verify $form_state['view'] is defined, and it is an object (and not an array, for example).