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 public $_defaults = [];
32 public $submitOnce = TRUE;
35 * Get the tpl file name.
39 public function getTemplateFileName() {
40 return 'CRM/Form/basicForm.tpl';
44 * Set default values for the form.
46 * Default values are retrieved from the database.
48 public function setDefaultValues() {
49 $this->setDefaultsForMetadataDefinedFields();
50 return $this->_defaults
;
54 * Build the form object.
56 public function buildQuickForm() {
57 $this->addFieldsDefinedInSettingsMetadata();
59 // @todo - do we still like this redirect?
60 CRM_Core_Session
::singleton()->pushUserContext(CRM_Utils_System
::url('civicrm/admin', 'reset=1'));
69 'name' => ts('Cancel'),
75 * Process the form submission.
77 public function postProcess() {
78 $params = $this->controller
->exportValues($this->_name
);
80 $this->saveMetadataDefinedSettings($params);
82 catch (CiviCRM_API3_Exception
$e) {
83 CRM_Core_Session
::setStatus($e->getMessage(), ts('Save Failed'), 'error');