Currently there are 3 ways in which the values from the searchForm are retrieved
1) the search form sets a value 'searchFormName' on the form during search which can
be later retrieved
2) the search task has an action that reflects the form it came from
3) as per 2 but there is additional handling for the fact it might be
the contact search (knowable because the entity has been set to 'Contact'
I'm not 100% sure at this stage that the selected method (3) in this PR is the best -
but it seems 'as good' as 1 with less form-state stuff and this PR consolidates it
into 1 place so it is handled consistently
/**
* Common pre-process function.
*
- * @param CRM_Core_Form $form
+ * @param \CRM_Core_Form_Task $form
*
* @throws \CRM_Core_Exception
*/
public static function preProcessCommon(&$form) {
$form->_activityHolderIds = [];
- $values = $form->controller->exportValues($form->get('searchFormName'));
+ $values = $form->getSearchFormValues();
$form->_task = $values['task'];
$activityTasks = CRM_Activity_Task::tasks();
* Processing needed for buildForm and later.
*/
public function preProcess() {
+ // SearchFormName is deprecated & to be removed - the replacement is for the task to
+ // call $this->form->getSearchFormValues()
+ // A couple of extensions use it.
$this->set('searchFormName', 'Search');
//check for civicase access.
* Processing needed for buildForm and later.
*/
public function preProcess() {
+ // SearchFormName is deprecated & to be removed - the replacement is for the task to
+ // call $this->form->getSearchFormValues()
+ // A couple of extensions use it.
$this->set('searchFormName', 'Advanced');
parent::preProcess();
* Processing needed for buildForm and later.
*/
public function preProcess() {
+ // SearchFormName is deprecated & to be removed - the replacement is for the task to
+ // call $this->form->getSearchFormValues()
+ // A couple of extensions use it.
$this->set('searchFormName', 'Basic');
parent::preProcess();
* Build the form object.
*/
public function preProcess() {
+ // SearchFormName is deprecated & to be removed - the replacement is for the task to
+ // call $this->form->getSearchFormValues()
+ // A couple of extensions use it.
$this->set('searchFormName', 'Builder');
$this->set('context', 'builder');
protected $_customClass = NULL;
public function preProcess() {
+ // SearchFormName is deprecated & to be removed - the replacement is for the task to
+ // call $this->form->getSearchFormValues()
+ // A couple of extensions use it.
$this->set('searchFormName', 'Custom');
$this->set('context', 'custom');
$fragment .= '/custom';
}
if (!$isStandAlone) {
- self::$_searchFormValues = $form->getFormValues();
+ self::$_searchFormValues = $form->getSearchFormValues();
}
//set the user context for redirection of task actions
* @throws \CRM_Core_Exception
*/
public function preProcess() {
+ // SearchFormName is deprecated & to be removed - the replacement is for the task to
+ // call $this->form->getSearchFormValues()
+ // A couple of extensions use it.
$this->set('searchFormName', 'Search');
$this->_actionButtonName = $this->getButtonName('next', 'action');
}
/**
- * @param CRM_Core_Form $form
+ * @param \CRM_Core_Form_Task $form
+ *
+ * @throws \CRM_Core_Exception
*/
public static function preProcessCommon(&$form) {
$form->_contributionIds = [];
- $values = $form->controller->exportValues($form->get('searchFormName'));
+ $values = $form->getSearchFormValues();
$form->_task = $values['task'] ?? NULL;
$contributeTasks = CRM_Contribute_Task::tasks();
public static function preProcessCommon(&$form) {
$form->_entityIds = [];
- $searchFormValues = $form->controller->exportValues($form->get('searchFormName'));
+ $searchFormValues = $form->getSearchFormValues();
$form->_task = $searchFormValues['task'];
$className = 'CRM_' . ucfirst($form::$entityShortname) . '_Task';
*
* @return array
*/
- public function getFormValues() {
+ public function getSearchFormValues() {
if ($this->_action === CRM_Core_Action::ADVANCED) {
return $this->controller->exportValues('Advanced');
}
if ($this->_action == CRM_Core_Action::COPY) {
return $this->controller->exportValues('Custom');
}
+ if ($this->get('entity') !== 'Contact') {
+ return $this->controller->exportValues('Search');
+ }
return $this->controller->exportValues('Basic');
}
* @throws \CiviCRM_API3_Exception
*/
public function preProcess() {
+ // SearchFormName is deprecated & to be removed - the replacement is for the task to
+ // call $this->form->getSearchFormValues()
+ // A couple of extensions use it.
$this->set('searchFormName', 'Search');
/**
}
/**
- * @param CRM_Core_Form $form
+ * @param CRM_Core_Form_Task $form
*/
public static function preProcessCommon(&$form) {
$form->_participantIds = [];
- $values = $form->controller->exportValues($form->get('searchFormName'));
+ $values = $form->getSearchFormValues();
$form->_task = $values['task'];
$tasks = CRM_Event_Task::permissionedTaskTitles(CRM_Core_Permission::getPermission());
$this::$tableName = CRM_Core_DAO_AllCoreTables::getTableForClass(CRM_Core_DAO_AllCoreTables::getFullName($this->getDAOName()));
}
- // get the submitted values based on search
- if ($this->_action == CRM_Core_Action::ADVANCED) {
- $values = $this->controller->exportValues('Advanced');
- }
- elseif ($this->_action == CRM_Core_Action::PROFILE) {
- $values = $this->controller->exportValues('Builder');
- }
- elseif ($this->_action == CRM_Core_Action::COPY) {
- $values = $this->controller->exportValues('Custom');
- }
- else {
- if ($entityShortname !== 'Contact') {
- $values = $this->controller->exportValues('Search');
- }
- else {
- $values = $this->controller->exportValues('Basic');
- }
- }
+ $values = $this->getSearchFormValues();
$count = 0;
$this->_matchingContacts = FALSE;
}
/**
- * @param CRM_Core_Form $form
+ * @param \CRM_Core_Form_Task $form
+ *
+ * @throws \CRM_Core_Exception
*/
public static function preProcessCommon(&$form) {
$form->_grantIds = [];
- $values = $form->controller->exportValues($form->get('searchFormName'));
+ $values = $form->getSearchFormValues();
$form->_task = $values['task'];
$tasks = CRM_Grant_Task::tasks();
}
/**
- * @param CRM_Core_Form $form
+ * @param \CRM_Core_Form_Task $form
+ *
+ * @throws \CRM_Core_Exception
*/
public static function preProcessCommon(&$form) {
- $values = $form->controller->exportValues($form->get('searchFormName'));
+ $values = $form->getSearchFormValues();
$form->_task = $values['task'] ?? NULL;
$mailingTasks = CRM_Mailing_Task::tasks();
* @throws \CiviCRM_API3_Exception
*/
public function preProcess() {
+ // SearchFormName is deprecated & to be removed - the replacement is for the task to
+ // call $this->form->getSearchFormValues()
+ // A couple of extensions use it.
$this->set('searchFormName', 'Search');
$this->_actionButtonName = $this->getButtonName('next', 'action');
}
/**
- * @param CRM_Core_Form $form
+ * @param \CRM_Core_Form_Task $form
*
* @throws \CRM_Core_Exception
*/
public static function preProcessCommon(&$form) {
$form->_memberIds = [];
- $values = $form->controller->exportValues($form->get('searchFormName'));
+ $values = $form->getSearchFormValues();
$form->_task = $values['task'];
$tasks = CRM_Member_Task::permissionedTaskTitles(CRM_Core_Permission::getPermission());
}
// Assert contribIds are returned in a sorted order.
- $form = new CRM_Contribute_Form_Task();
- $form->controller = new CRM_Core_Controller();
+ $form = $this->getFormObject('CRM_Contribute_Form_Task', [], 'Search');
foreach ($fields as $val) {
$form->set(CRM_Utils_Sort::SORT_ORDER, "`{$val}` asc");
CRM_Contribute_Form_Task::preProcessCommon($form);