APIv4 - Fix customValue fieldSpec to include input types & labels
authorColeman Watts <coleman@civicrm.org>
Wed, 5 Apr 2023 18:53:53 +0000 (14:53 -0400)
committerColeman Watts <coleman@civicrm.org>
Wed, 5 Apr 2023 18:53:53 +0000 (14:53 -0400)
Civi/Api4/Service/Spec/Provider/CustomValueSpecProvider.php

index c4c1cb8a2b8a15f77e6e77c5ead35f68f469aa9d..2cb57becd162509a74ec3c2411e2914ef1083237 100644 (file)
@@ -26,21 +26,24 @@ class CustomValueSpecProvider extends \Civi\Core\Service\AutoService implements
    */
   public function modifySpec(RequestSpec $spec) {
     $action = $spec->getAction();
-    if ($action !== 'create') {
-      $idField = new FieldSpec('id', $spec->getEntity(), 'Integer');
-      $idField->setType('Field');
-      $idField->setColumnName('id');
-      $idField->setTitle(ts('Custom Value ID'));
-      $idField->setReadonly(TRUE);
-      $spec->addFieldSpec($idField);
-    }
+
+    $idField = new FieldSpec('id', $spec->getEntity(), 'Integer');
+    $idField->setType('Field');
+    $idField->setInputType('Number');
+    $idField->setColumnName('id');
+    $idField->setTitle(ts('Custom Value ID'));
+    $idField->setReadonly(TRUE);
+    $spec->addFieldSpec($idField);
+
     $entityField = new FieldSpec('entity_id', $spec->getEntity(), 'Integer');
     $entityField->setType('Field');
     $entityField->setColumnName('entity_id');
     $entityField->setTitle(ts('Entity ID'));
+    $entityField->setLabel(ts('Contact'));
     $entityField->setRequired($action === 'create');
     $entityField->setFkEntity('Contact');
     $entityField->setReadonly(TRUE);
+    $entityField->setInputType('EntityRef');
     $spec->addFieldSpec($entityField);
   }