From db3ec100917b2f7dc59f9ed68152f82ab3f4e622 Mon Sep 17 00:00:00 2001 From: Tim Mallezie Date: Thu, 30 Apr 2015 17:45:10 +0200 Subject: [PATCH] use addField in CRM_Contact_Form_Relationship, add Date support to AddField --- CRM/Contact/Form/Relationship.php | 28 +++++++++------------------- CRM/Core/Form.php | 10 +++++++--- xml/schema/Contact/Relationship.xml | 24 ++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/CRM/Contact/Form/Relationship.php b/CRM/Contact/Form/Relationship.php index e8812d5367..cf53a1b90f 100644 --- a/CRM/Contact/Form/Relationship.php +++ b/CRM/Contact/Form/Relationship.php @@ -335,20 +335,11 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { } $this->assign('relationshipData', $jsData); - $this->add( - 'select', - 'relationship_type_id', - ts('Relationship Type'), - array('' => ts('- select -')) + $relationshipList, - TRUE, - array('class' => 'crm-select2 huge') - ); + $this->addField('relationship_type_id', array('options' => array('' => ts('- select -')) + $relationshipList, 'class' => 'huge', 'placeholder' => '- select -'), TRUE); $label = $this->_action & CRM_Core_Action::ADD ? ts('Contact(s)') : ts('Contact'); - $contactField = $this->addEntityRef('related_contact_id', $label, array( - 'multiple' => TRUE, - 'create' => TRUE, - ), TRUE); + $contactField = $this->addField('related_contact_id', array('label' => $label, 'name' => 'contact_id_b', 'multiple' => TRUE, + 'create' => TRUE,), TRUE); // This field cannot be updated if ($this->_action & CRM_Core_Action::UPDATE) { $contactField->freeze(); @@ -356,16 +347,15 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { $this->add('advcheckbox', 'is_current_employer', $this->_contactType == 'Organization' ? ts('Current Employee') : ts('Current Employer')); - $this->addDate('start_date', ts('Start Date'), FALSE, array('formatType' => 'searchDate')); - $this->addDate('end_date', ts('End Date'), FALSE, array('formatType' => 'searchDate')); + $this->addField('start_date', array('label' => ts('Start Date'), 'formatType' => 'searchDate')); + $this->addField('end_date', array('label' => ts('End Date'), 'formatType' => 'searchDate')); - $this->add('advcheckbox', 'is_active', ts('Enabled?')); + $this->addField('is_active', array('label' => ts('Enabled?'))); - // CRM-14612 - Don't use adv-checkbox as it interferes with the form js - $this->add('checkbox', 'is_permission_a_b'); - $this->add('checkbox', 'is_permission_b_a'); + $this->addField('is_permission_a_b'); + $this->addField('is_permission_b_a'); - $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Relationship', 'description')); + $this->addField('description', array('label' => ts('Description'))); CRM_Contact_Form_Edit_Notes::buildQuickForm($this); diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 4bddc368b0..ae820a4230 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -1272,9 +1272,13 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $this->addElement('textarea', $name, $label, $props, $required); break; - //case 'Select Date': - //TODO: Add date formats - //TODO: Add javascript template for dates. + case 'Select Date': + //TODO: add range support + //TODO: Add date formats + //TODO: Add javascript template for dates. + $this->addDate($name, $label, $required, $props); + break; + case 'Radio': $separator = isset($props['separator']) ? $props['separator'] : NULL; unset($props['separator']); diff --git a/xml/schema/Contact/Relationship.xml b/xml/schema/Contact/Relationship.xml index b3be05c34d..92e7ec4490 100644 --- a/xml/schema/Contact/Relationship.xml +++ b/xml/schema/Contact/Relationship.xml @@ -41,6 +41,9 @@ true id of the second contact 1.1 + + EntityRef + contact_id_b @@ -56,6 +59,9 @@ true id of the relationship 1.1 + + Select + relationship_type_id @@ -70,6 +76,9 @@ Relationship Start Date date when the relationship started 1.1 + + Select Date + end_date @@ -77,6 +86,9 @@ Relationship End Date date when the relationship ended 1.1 + + Select Date + is_active @@ -85,6 +97,9 @@ 1 is the relationship active ? 1.1 + + CheckBox + description @@ -93,6 +108,9 @@ 255 Optional verbose description for the relationship. 1.5 + + Text + is_permission_a_b @@ -103,6 +121,9 @@ related data for contact b ? 2.1 + + CheckBox + is_permission_b_a @@ -113,6 +134,9 @@ related data for contact a ? 2.1 + + CheckBox + case_id -- 2.25.1