Notice: Trying to get property of non-object I have created a module, and I am trying to use the following code: 

function mymodule_form_alter(&amp;$form, &amp;$form_state, $form_id) {     
  if ($form_state['view']-&gt;name == 'album1') {
    // ...
  }
  // ...
}


The line that causes the error is the following one: 

if ($form_state['view']-&gt;name == 'album1') {


The error I get is the following one:


  Notice: Trying to get property of non-object in mymodule_form_alter() (line 15 of C:\xampp\htdocs\drupal\sites\all\modules\mymodule\mymodule.module).
$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).