Skip to content

Commit

Permalink
Adds CRM_Core_Form::isFormInViewMode and CRM_Core_Form::isFormInEditM…
Browse files Browse the repository at this point in the history
…ode (useful for extensions implementing buildForm)
  • Loading branch information
mlutfy committed Jun 17, 2020
1 parent 8d61cdb commit 99dfc0b
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions CRM/Core/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2575,18 +2575,41 @@ public function getCurrency($submittedValues = []) {
*
* @return bool
*/
public function isFormInViewOrEditMode() {
protected function isFormInViewOrEditMode() {
return $form->isFormInViewMode() || $form->isFormInEditMode();
}

/**
* Is the form in edit mode.
*
* Helper function, notably for extensions implementing the buildForm hook,
* so that they can return early.
*
* @return bool
*/
public function isFormInEditMode() {
return in_array($this->_action, [
CRM_Core_Action::UPDATE,
CRM_Core_Action::ADD,
CRM_Core_Action::VIEW,
CRM_Core_Action::BROWSE,
CRM_Core_Action::BASIC,
CRM_Core_Action::ADVANCED,
CRM_Core_Action::PREVIEW,
]);
}

/**
* Is the form in view mode.
*
* Helper function, notably for extensions implementing the buildForm hook,
* so that they can return early.
*
* @return bool
*/
public function isFormInViewMode() {
return $this->_action == CRM_Core_Action::VIEW;
}

/**
* Set the active tab
*
Expand Down

0 comments on commit 99dfc0b

Please sign in to comment.