Add/Update form actions(context?) detection from hook_buildForm
This should be it:

    $mode = $form-&gt;getVar('_mode');
    // civicrm mumbo jumbo below targets EDIT form mode
    if (in_array($mode, array(CRM_Profile_Form::MODE_EDIT))) 
    {}


But it doesn't work for all forms, so, for example, for Relationship add/edit form, we should check if $form->getVar('_relationshipId')  isset/empty :
thus no Relationship has been created  yet: we are in Relationship ADD "mode".