3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Generic metadata based settings form.
21 * The form filter will determine the settings displayed.
23 class CRM_Admin_Form_Generic
extends CRM_Core_Form
{
24 use CRM_Admin_Form_SettingTrait
;
26 protected $_settings = [];
27 protected $includesReadOnlyFields = FALSE;
28 public $_defaults = [];
31 * Get the tpl file name.
35 public function getTemplateFileName() {
36 return 'CRM/Form/basicForm.tpl';
40 * Set default values for the form.
42 * Default values are retrieved from the database.
44 public function setDefaultValues() {
45 $this->setDefaultsForMetadataDefinedFields();
46 return $this->_defaults
;
50 * Build the form object.
52 public function buildQuickForm() {
53 $this->addFieldsDefinedInSettingsMetadata();
55 // @todo look at sharing the code below in the settings trait.
56 if ($this->includesReadOnlyFields
) {
57 CRM_Core_Session
::setStatus(ts("Some fields are loaded as 'readonly' as they have been set (overridden) in civicrm.settings.php."), '', 'info', ['expires' => 0]);
60 // @todo - do we still like this redirect?
61 CRM_Core_Session
::singleton()->pushUserContext(CRM_Utils_System
::url('civicrm/admin', 'reset=1'));
70 'name' => ts('Cancel'),
76 * Process the form submission.
78 public function postProcess() {
79 $params = $this->controller
->exportValues($this->_name
);
81 $this->saveMetadataDefinedSettings($params);
83 catch (CiviCRM_API3_Exception
$e) {
84 CRM_Core_Session
::setStatus($e->getMessage(), ts('Save Failed'), 'error');