From a6413da67a4579866f0fd0323ddb23a7b6b9654a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 18 Sep 2026 17:00:53 +0000
Subject: [PATCH] =Cleaning up the Integrations setup a bit, started the Helcim integration work too
---
inc/registrar/helpers/AddCustomFields.php | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/inc/registrar/helpers/AddCustomFields.php b/inc/registrar/helpers/AddCustomFields.php
index 2be7fd2..1cccca9 100644
--- a/inc/registrar/helpers/AddCustomFields.php
+++ b/inc/registrar/helpers/AddCustomFields.php
@@ -99,10 +99,14 @@
$schema = is_array($rawSchema) ? $this->schema($rawSchema) : $rawSchema;
+ $default = $config['type'] === 'repeater' ?
+ $this->determineDefault($schema['schema']['properties']??[]) :
+ $config['default'] ?? MetaTypeManager::getType($config['type'])['default'] ?? '';
+
register_post_meta($this->registrar->getBased(), jvbCheckBase($name), [
'single' => true,
'type' => $metaType,
- 'default' => $config['default'] ?? MetaTypeManager::getType($config['type'])['default'] ?? '',
+ 'default' => $default,
'sanitize_callback' => fn($value) => (Sanitizer::sanitize($value, $config)),
'auth_callback' => fn($allowed, $key, $postID) => current_user_can('edit_post', $postID),
'show_in_rest' => $schema,
@@ -285,4 +289,16 @@
{
}
+
+ protected function determineDefault(array $properties):array
+ {
+ $out = [];
+ foreach ($properties as $prop => $value) {
+ $out[$prop] = match ($value) {
+ 'object' => [],
+ default => ''
+ };
+ }
+ return $out;
+ }
}
--
Gitblit v1.10.0