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
21 * This class generates form components
22 * for previewing Civicrm Profile Group
25 class CRM_UF_Form_AbstractPreview
extends CRM_Core_Form
{
28 * The fields needed to build this form.
35 * Set the profile/field structure for this form
37 * @param array $fields
38 * List of fields per CRM_Core_BAO_UFGroup::formatUFFields or CRM_Core_BAO_UFGroup::getFields.
39 * @param bool $isSingleField
42 public function setProfile($fields, $isSingleField = FALSE, $flag = FALSE) {
44 $this->assign('previewField', $isSingleField);
48 $this->assign('viewOnly', FALSE);
51 $this->assign('viewOnly', TRUE);
54 $this->set('fieldId', NULL);
55 $this->assign("fields", $fields);
56 $this->_fields
= $fields;
60 * Set the default form values.
64 * the default array reference
66 public function setDefaultValues() {
68 foreach ($this->_fields
as $name => $field) {
69 if ($customFieldID = CRM_Core_BAO_CustomField
::getKeyID($field['name'])) {
70 CRM_Core_BAO_CustomField
::setProfileDefaults($customFieldID, $name, $defaults, NULL, CRM_Profile_Form
::MODE_REGISTER
);
74 //set default for country.
75 CRM_Core_BAO_UFGroup
::setRegisterDefaults($this->_fields
, $defaults);
81 * Build the form object.
85 public function buildQuickForm() {
86 foreach ($this->_fields
as $name => $field) {
87 if (empty($field['is_view'])) {
88 CRM_Core_BAO_UFGroup
::buildProfile($this, $field, CRM_Profile_Form
::MODE_CREATE
);
94 * Use the form name to create the tpl file name.
102 public function getTemplateFileName() {
103 return 'CRM/UF/Form/Preview.tpl';