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 * This class generates form components
20 * for previewing Civicrm Profile Group
23 class CRM_UF_Form_AbstractPreview
extends CRM_Core_Form
{
26 * The fields needed to build this form.
33 * Set the profile/field structure for this form
35 * @param array $fields
36 * List of fields per CRM_Core_BAO_UFGroup::formatUFFields or CRM_Core_BAO_UFGroup::getFields.
37 * @param bool $isSingleField
40 public function setProfile($fields, $isSingleField = FALSE, $flag = FALSE) {
42 $this->assign('previewField', $isSingleField);
46 $this->assign('viewOnly', FALSE);
49 $this->assign('viewOnly', TRUE);
52 $this->set('fieldId', NULL);
53 $this->assign("fields", $fields);
54 $this->_fields
= $fields;
58 * Set the default form values.
62 * the default array reference
64 public function setDefaultValues() {
66 foreach ($this->_fields
as $name => $field) {
67 if ($customFieldID = CRM_Core_BAO_CustomField
::getKeyID($field['name'])) {
68 CRM_Core_BAO_CustomField
::setProfileDefaults($customFieldID, $name, $defaults, NULL, CRM_Profile_Form
::MODE_REGISTER
);
72 //set default for country.
73 CRM_Core_BAO_UFGroup
::setRegisterDefaults($this->_fields
, $defaults);
79 * Build the form object.
83 public function buildQuickForm() {
84 foreach ($this->_fields
as $name => $field) {
85 if (empty($field['is_view'])) {
86 CRM_Core_BAO_UFGroup
::buildProfile($this, $field, CRM_Profile_Form
::MODE_CREATE
);
92 * Use the form name to create the tpl file name.
100 public function getTemplateFileName() {
101 return 'CRM/UF/Form/Preview.tpl';