diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 481a38f5dad8..9070bf7c7ba2 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -2575,11 +2575,22 @@ 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, @@ -2587,6 +2598,18 @@ public function isFormInViewOrEditMode() { ]); } + /** + * 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 *