2

Is it possible in hook_buildForm to define which "$action" link (view/add/update/delete/etc) opens the form? We need to set different $defaults depending on "context". There is such kind of detection/check in TPL files, but what about hook_buildForm?

1

This should be it:

    $mode = $form->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".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.