CRM-17757 - Fix metadata for CRM_Core_Form::addField
authorColeman Watts <coleman@civicrm.org>
Tue, 29 Dec 2015 23:09:24 +0000 (18:09 -0500)
committerColeman Watts <coleman@civicrm.org>
Tue, 29 Dec 2015 23:10:16 +0000 (18:10 -0500)
13 files changed:
CRM/Core/Form.php
xml/schema/Activity/Activity.xml
xml/schema/Batch/Batch.xml
xml/schema/Campaign/Campaign.xml
xml/schema/Case/CaseContact.xml
xml/schema/Contact/Contact.xml
xml/schema/Contribute/Contribution.xml
xml/schema/Event/Event.xml
xml/schema/Grant/Grant.xml
xml/schema/Member/Membership.xml
xml/schema/PCP/PCP.xml
xml/schema/Pledge/Pledge.xml
xml/schema/SMS/History.xml

index 183f4b40c793d496fb2278b434de54260889f320..ab3e9e89de544d3535a88158c4392c54bc4e2516 100644 (file)
@@ -1342,26 +1342,27 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
    */
   public function addField($name, $props = array(), $required = FALSE) {
     // Resolve context.
-    if (!isset($props['context'])) {
+    if (empty($props['context'])) {
       $props['context'] = $this->getDefaultContext();
     }
+    $context = $props['context'];
     // Resolve entity.
-    if (!isset($props['entity'])) {
+    if (empty($props['entity'])) {
       $props['entity'] = $this->getDefaultEntity();
     }
     // Resolve field.
-    if (!isset($props['name'])) {
+    if (empty($props['name'])) {
       $props['name'] = strrpos($name, '[') ? rtrim(substr($name, 1 + strrpos($name, '[')), ']') : $name;
     }
     // Resolve action.
-    if (!isset($props['action'])) {
+    if (empty($props['action'])) {
       $props['action'] = $this->getApiAction();
     }
 
     // Handle custom fields
     if (strpos($name, 'custom_') === 0 && is_numeric($name[7])) {
       $fieldId = (int) substr($name, 7);
-      return CRM_Core_BAO_CustomField::addQuickFormElement($this, $name, $fieldId, $required, $props['context'] == 'search', CRM_Utils_Array::value('label', $props));
+      return CRM_Core_BAO_CustomField::addQuickFormElement($this, $name, $fieldId, $required, $context == 'search', CRM_Utils_Array::value('label', $props));
     }
 
     // Core field - get metadata.
@@ -1370,7 +1371,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
     $label = CRM_Utils_Array::value('label', $props, isset($fieldSpec['title']) ? $fieldSpec['title'] : NULL);
 
     $widget = isset($props['type']) ? $props['type'] : $fieldSpec['html']['type'];
-    if ($widget == 'TextArea' && $props['context'] == 'search') {
+    if ($widget == 'TextArea' && $context == 'search') {
       $widget = 'Text';
     }
 
@@ -1389,13 +1390,13 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
       else {
         $options = isset($fieldSpec['options']) ? $fieldSpec['options'] : NULL;
       }
-      if ($props['context'] == 'search') {
+      if ($context == 'search') {
         $widget = 'Select';
         $props['multiple'] = CRM_Utils_Array::value('multiple', $props, TRUE);
       }
 
       // Add data for popup link.
-      if ((!empty($props['option_url']) || !array_key_exists('option_url', $props)) && ($props['context'] != 'search' && $widget == 'Select' && CRM_Core_Permission::check('administer CiviCRM'))) {
+      if ((!empty($props['option_url']) || !array_key_exists('option_url', $props)) && ($context != 'search' && $widget == 'Select' && CRM_Core_Permission::check('administer CiviCRM'))) {
         $props['data-option-edit-path'] = !empty($props['option_url']) ? $props['option_url'] : CRM_Core_PseudoConstant::getOptionEditUrl($fieldSpec);
         $props['data-api-entity'] = $props['entity'];
         $props['data-api-field'] = $props['name'];
@@ -1441,14 +1442,14 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
         $props += array(
           'required' => $required,
           'label' => $label,
-          'multiple' => $props['context'] == 'search',
+          'multiple' => $context == 'search',
         );
         return $this->addChainSelect($name, $props);
 
       case 'Select':
         $props['class'] = CRM_Utils_Array::value('class', $props, 'big') . ' crm-select2';
         if (!array_key_exists('placeholder', $props)) {
-          $props['placeholder'] = $required ? ts('- select -') : $props['context'] == 'search' ? ts('- any -') : ts('- none -');
+          $props['placeholder'] = $required ? ts('- select -') : $context == 'search' ? ts('- any -') : ts('- none -');
         }
         // TODO: Add and/or option for fields that store multiple values
         return $this->add('select', $name, $label, $options, $required, $props);
@@ -1472,7 +1473,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
 
       case 'File':
         // We should not build upload file in search mode.
-        if ($props['context'] == 'search') {
+        if ($context == 'search') {
           return;
         }
         $file = $this->add('file', $name, $label, $props, $required);
index 59348ba6b63e13acfc47d5a2fc99d1fe4c952b14..4948f49de819efec506bf6e7eba12733c1ad107c 100644 (file)
     <comment>Phone ID of the number called (optional - used if an existing phone number is selected).</comment>
     <add>2.0</add>
     <html>
-      <type>Autocomplete-Select</type>
+      <type>EntityRef</type>
     </html>
   </field>
   <foreignKey>
index 9477065c9ff41d54f44e708f1b0d247ba816a77c..449c6c1bc41839a724a77d971a28f5b06aa6aa34 100644 (file)
     <comment>FK to Saved Search ID</comment>
     <add>4.1</add>
     <html>
-      <type>Autocomplete-Select</type>
+      <type>EntityRef</type>
     </html>
   </field>
   <foreignKey>
index 01e67670619b97b1b63bae78e845e6e857497349..da4ec8cbb073ac9872b0409bac7504a324889899 100644 (file)
     <import>true</import>
     <add>3.3</add>
     <html>
-      <type>Autocomplete-Select</type>
+      <type>EntityRef</type>
     </html>
   </field>
   <foreignKey>
index 218dbcce41b24fc121f1235f23bfb860dbc1b42f..43c83100954a9df49228a4233aa2220e6be1acc0 100644 (file)
@@ -38,7 +38,7 @@
       <required>true</required>
       <comment>Contact ID of contact record given case belongs to.</comment>
       <html>
-        <type>Autocomplete-Select</type>
+        <type>EntityRef</type>
       </html>
       <add>2.1</add>
   </field>
index 52739de3c3ac3f03982da333a78a8551ed9703e0..bcf7c8f3855869528500bb094bfd7c4d828ef227 100644 (file)
       <condition>parent_id IS NOT NULL</condition>
     </pseudoconstant>
     <html>
-      <type>Multi-Select</type>
+      <type>Select</type>
+      <multiple>1</multiple>
     </html>
     <add>1.5</add>
   </field>
   <index>
     <name>index_contact_sub_type</name>
     <fieldName>contact_sub_type</fieldName>
-    <html>
-      <type>Multi-Select</type>
-    </html>
     <add>2.1</add>
   </index>
   <field>
     <export>true</export>
     <add>2.1</add>
     <html>
-      <type>Autocomplete-Select</type>
+      <type>EntityRef</type>
     </html>
   </field>
   <foreignKey>
index 84c80292a8d070c6f19b79c6763e8ee0f03ffe6d..db883c14e63fb91a3b05fd1e676ab48c3cb092c6 100644 (file)
@@ -31,7 +31,7 @@
     <dataPattern>/^\d+$/</dataPattern>
     <comment>FK to Contact ID</comment>
     <html>
-       <type>Autocomplete-Select</type>
+       <type>EntityRef</type>
      </html>
     <add>1.3</add>
   </field>
index 25bd248e214fe43e99f6214afdff384e99ef3941..decd8a8cb3adbabd9361a11e096600ed553bce64 100644 (file)
     </pseudoconstant>
     <add>3.4</add>
     <html>
-       <type>Autocomplete-Select</type>
+       <type>EntityRef</type>
      </html>
   </field>
   <foreignKey>
     <default>NULL</default>
     <comment>Implicit FK to civicrm_event: parent event</comment>
     <html>
-       <type>Autocomplete-Select</type>
+       <type>EntityRef</type>
      </html>
     <add>4.1</add>
   </field>
index 0cd308dd84711603f22c6c869316c1cb04b256a5..ebb27f30a8ab70238d77ee6c90c0a7b84463a552 100644 (file)
@@ -30,7 +30,7 @@
     <comment>Contact ID of contact record given grant belongs to.</comment>
     <add>1.8</add>
     <html>
-       <type>Autocomplete-Select</type>
+       <type>EntityRef</type>
      </html>
   </field>
   <foreignKey>
index 15de8ff8276d08f02c21d86991334d05da78a793..53336f081e3fe1b1f8336a418149b53e12980da7 100644 (file)
@@ -35,7 +35,7 @@
     <comment>FK to Contact ID</comment>
     <add>1.5</add>
     <html>
-      <type>Autocomplete-Select</type>
+      <type>EntityRef</type>
     </html>
   </field>
   <foreignKey>
index b5fcabf820c230cd7da714c15ac6023dca46a9f4..46f66b6c30c7cb06541ad5a86bee959dcce6f41b 100644 (file)
@@ -28,7 +28,7 @@
     <comment>FK to Contact ID</comment>
     <add>2.2</add>
     <html>
-      <type>Autocomplete-Select</type>
+      <type>EntityRef</type>
     </html>
   </field>
   <foreignKey>
index 86ab5b921c31cf08d80b4bd8b84e8a456e3bacb0..e407d86c70e903757bcff3625fa79c068d4cb05a 100644 (file)
@@ -29,7 +29,7 @@
     <comment>Foreign key to civicrm_contact.id .</comment>
     <add>2.1</add>
     <html>
-       <type>Autocomplete-Select</type>
+       <type>EntityRef</type>
      </html>
   </field>
   <foreignKey>
index 550b4b8a2c2e42911d3fbb02554f2459e954040e..0cd60b2ae43593549f5761b2adaa0142a5734e24 100644 (file)
@@ -36,7 +36,7 @@
     <comment>FK to Contact who is sending this SMS</comment>
     <add>1.4</add>
     <html>
-      <type>Autocomplete-Select</type>
+      <type>EntityRef</type>
     </html>
   </field>
   <foreignKey>