From c4aa5cdb5e90ad4b420e22772797d16980232a2b Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 15 Apr 2026 18:38:55 +0000
Subject: [PATCH] =Updating custom tables to utilize CustomTable.php

---
 inc/registrar/fields/Field.php |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/inc/registrar/fields/Field.php b/inc/registrar/fields/Field.php
index e34c80e..7b902cb 100644
--- a/inc/registrar/fields/Field.php
+++ b/inc/registrar/fields/Field.php
@@ -19,6 +19,8 @@
 	protected bool $quickEdit = true;	// whether to show in quick edit table
 	protected bool $quill;				// whether to use quill
 	protected int $maxLength;			// of characters
+	protected string $subtype;
+	protected array $allowedSubtype = ['text', 'url','number','tel','email','number'];
 	/**
 	 * @var ?bool For timeline post types. Indicates whether all posts get this field, or just the parent
 	 */
@@ -50,7 +52,7 @@
 
 		foreach ($config as $key => $value) {
 			if (property_exists($class, $key)) {
-				$method = 'set' . ucfirst($key);
+				$method = 'set'.implode('',array_map('ucfirst',explode('_', $key)));;
 				$class->$method($value);
 			} else {
 				error_log('Instance: '.print_r($class, true));
@@ -131,16 +133,16 @@
 	public function getConfig():array{
 		$config = get_object_vars($this);
 
-		$config = array_map(function ($item) {
+		return array_map(function ($item) {
 			if (is_a($item, Field::class)) {
 				return $item->getConfig();
 			} else if (is_array($item)) {
 				$temp = [];
-				foreach ($item as $v) {
+				foreach ($item as $k => $v) {
 					if (is_a($v, Field::class)) {
-						$temp[] = $v->getConfig();
+						$temp[$k] = $v->getConfig();
 					} else {
-						$temp[] = $v;
+						$temp[$k] = $v;
 					}
 				}
 				return $temp;
@@ -148,7 +150,17 @@
 				return $item;
 			}
 		}, $config);
-
-		return $config;
+	}
+	public function setSubtype(string $subtype):void
+	{
+		if (!in_array($subtype, $this->allowedSubtype)) {
+			error_log('[SelectorField]Attempted subtype not allowed: '.$subtype);
+			return;
+		}
+		$this->subtype = $subtype;
+	}
+	public function getSubtype():string
+	{
+		return $this->subtype;
 	}
 }

--
Gitblit v1.10.0