Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CRM_Core_Form::isFormInViewMode and CRM_Core_Form::isFormInEditMode #17637

Merged
merged 2 commits into from
Jun 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion CRM/Core/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2576,17 +2576,40 @@ public function getCurrency($submittedValues = []) {
* @return bool
*/
protected function isFormInViewOrEditMode() {
return $this->isFormInViewMode() || $this->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