CIVICRM-1846 Find Activities Search, default search option for Activity Text is set...
[civicrm-core.git] / CRM / Admin / Form / Generic.php
CommitLineData
f167c7a9 1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
f167c7a9 5 | |
bc77d7c0
TO
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
f167c7a9 9 +--------------------------------------------------------------------+
10 */
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
f167c7a9 16 */
17
18/**
19 * Generic metadata based settings form.
20 *
21 * The form filter will determine the settings displayed.
22 */
23class CRM_Admin_Form_Generic extends CRM_Core_Form {
24 use CRM_Admin_Form_SettingTrait;
25
26 protected $_settings = [];
f167c7a9 27 public $_defaults = [];
28
88aae6d4
A
29 /**
30 * @var bool
31 */
32 public $submitOnce = TRUE;
33
f167c7a9 34 /**
35 * Get the tpl file name.
36 *
37 * @return string
38 */
39 public function getTemplateFileName() {
40 return 'CRM/Form/basicForm.tpl';
41 }
42
43 /**
44 * Set default values for the form.
45 *
46 * Default values are retrieved from the database.
47 */
48 public function setDefaultValues() {
49 $this->setDefaultsForMetadataDefinedFields();
50 return $this->_defaults;
51 }
51f35276 52
f167c7a9 53 /**
54 * Build the form object.
55 */
56 public function buildQuickForm() {
f167c7a9 57 $this->addFieldsDefinedInSettingsMetadata();
58
f167c7a9 59 // @todo - do we still like this redirect?
60 CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1'));
be2fb01f 61 $this->addButtons([
0d48f1cc
TO
62 [
63 'type' => 'next',
64 'name' => ts('Save'),
65 'isDefault' => TRUE,
66 ],
67 [
68 'type' => 'cancel',
69 'name' => ts('Cancel'),
70 ],
71 ]);
f167c7a9 72 }
73
74 /**
75 * Process the form submission.
76 */
77 public function postProcess() {
78 $params = $this->controller->exportValues($this->_name);
79 try {
80 $this->saveMetadataDefinedSettings($params);
81 }
82 catch (CiviCRM_API3_Exception $e) {
83 CRM_Core_Session::setStatus($e->getMessage(), ts('Save Failed'), 'error');
84 }
85 }
86
87}