use addField in CRM_Contact_Form_Relationship, add Date support to AddField
authorTim Mallezie <tim.mallezie@chiro.be>
Thu, 30 Apr 2015 15:45:10 +0000 (17:45 +0200)
committerTim Mallezie <tim.mallezie@chiro.be>
Thu, 30 Apr 2015 15:45:10 +0000 (17:45 +0200)
CRM/Contact/Form/Relationship.php
CRM/Core/Form.php
xml/schema/Contact/Relationship.xml

index e8812d53670faa1bbabd9bffaa8952cabb018ae1..cf53a1b90f06da7bd9dd65e615f3bb3457c27e50 100644 (file)
@@ -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);
 
index 4bddc368b013d3a9baf264504e2140cc7709eea9..ae820a4230e4d043357e92e01937992dacfdc73d 100644 (file)
@@ -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']);
index b3be05c34d50a36d3d722006fdb4efe0c56283fa..92e7ec449033836352eefa4f49181ff6e8e9624b 100644 (file)
@@ -41,6 +41,9 @@
     <required>true</required>
     <comment>id of the second contact</comment>
     <add>1.1</add>
+    <html>
+      <type>EntityRef</type>
+    </html>
   </field>
   <foreignKey>
     <name>contact_id_b</name>
@@ -56,6 +59,9 @@
     <required>true</required>
     <comment>id of the relationship</comment>
     <add>1.1</add>
+    <html>
+      <type>Select</type>
+    </html>
   </field>
   <foreignKey>
     <name>relationship_type_id</name>
@@ -70,6 +76,9 @@
     <title>Relationship Start Date</title>
     <comment>date when the relationship started</comment>
     <add>1.1</add>
+    <html>
+      <type>Select Date</type>
+    </html>
   </field>
   <field>
     <name>end_date</name>
@@ -77,6 +86,9 @@
     <title>Relationship End Date</title>
     <comment>date when the relationship ended</comment>
     <add>1.1</add>
+    <html>
+      <type>Select Date</type>
+    </html>
   </field>
   <field>
     <name>is_active</name>
@@ -85,6 +97,9 @@
     <default>1</default>
     <comment>is the relationship active ?</comment>
     <add>1.1</add>
+    <html>
+      <type>CheckBox</type>
+    </html>
   </field>
   <field>
     <name>description</name>
     <length>255</length>
     <comment>Optional verbose description for the relationship.</comment>
     <add>1.5</add>
+    <html>
+      <type>Text</type>
+    </html>
   </field>
   <field>
     <name>is_permission_a_b</name>
       related data for contact b ?
     </comment>
     <add>2.1</add>
+    <html>
+      <type>CheckBox</type>
+    </html>
   </field>
   <field>
     <name>is_permission_b_a</name>
       related data for contact a ?
     </comment>
     <add>2.1</add>
+    <html>
+      <type>CheckBox</type>
+    </html>
   </field>
   <field>
     <name>case_id</name>