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 * Auxiliary class to provide support to the Contact Form class.
21 * Does this by implementing a small set of static methods.
23 class CRM_Contact_Form_Edit_Household
{
26 * This function provides the HTML form elements that are specific to the Household Contact Type.
28 * @param CRM_Core_Form $form
30 * @param int $inlineEditMode
31 * ( 1 for contact summary.
32 * top bar form and 2 for display name edit )
34 public static function buildQuickForm(&$form, $inlineEditMode = NULL) {
35 $form->applyFilter('__ALL__', 'trim');
37 if (!$inlineEditMode ||
$inlineEditMode == 1) {
39 $form->addField('household_name');
42 if (!$inlineEditMode ||
$inlineEditMode == 2) {
44 $form->addField('nick_name');
45 $form->addField('contact_source', ['label' => ts('Source')]);
48 if (!$inlineEditMode) {
49 $form->addField('external_identifier', ['label' => ts('External ID')]);
50 $form->addRule('external_identifier',
51 ts('External ID already exists in Database.'),
53 ['CRM_Contact_DAO_Contact', $form->_contactId
, 'external_identifier']
59 * Add rule for household.
61 * @param array $fields
62 * Array of form values.
65 * @param int $contactID
70 public static function formRule($fields, $files, $contactID = NULL) {
72 $primaryID = CRM_Contact_Form_Contact
::formRule($fields, $errors, $contactID, 'Household');
74 // make sure that household name is set
75 if (empty($fields['household_name'])) {
76 $errors['household_name'] = 'Household Name should be set.';
79 return empty($errors) ?
TRUE : $errors;