From 58e8ae0759ccfa97c478ccae4e0778bdce70966f Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Thu, 22 Jan 2026 22:40:02 +0000
Subject: [PATCH] =DirectoryManager.php updates, some javascript tweaks for CRUD.js, and minor style changes

---
 assets/js/concise/UtilityFunctions.js |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/assets/js/concise/UtilityFunctions.js b/assets/js/concise/UtilityFunctions.js
index 2381056..df3c75d 100644
--- a/assets/js/concise/UtilityFunctions.js
+++ b/assets/js/concise/UtilityFunctions.js
@@ -414,21 +414,25 @@
 }
 
 window.prefixInput = function(input, prefix, replace = false) {
+	if (!input) {
+		console.warn('prefixInput called with null/undefined input');
+		return;
+	}
 	let newId = replace ? prefix : `${prefix}${input.name}`;
-	if (input.labels.length > 0) {
+	if (input.labels && input.labels.length > 0) {
 		input.labels?.forEach(label => {
 			label.htmlFor = newId;
 		});
-	} else {
-		if (input.nextElementSibling?.tagName === 'LABEL') {
-			input.nextElementSibling.htmlFor = newId;
-		}else if (input.previousElementSibling?.tagName === 'LABEL') {
-			input.previousElementSibling.htmlFor = newId;
-		} else {
-			let label = input.parentElement.querySelector(`label[for="${input.id}"]`);
-			if (label) {
-				label.htmlFor = newId;
-			}
+	} else if (input.previousElementSibling?.tagName === 'label') {
+		let label = input.previousElementSibling;
+		if (label) label.htmlFor = newId;
+	} else if (input.nextElementSibling?.tagName === 'label') {
+		let label = input.nextElementSibling;
+		if (label) label.htmlFor = newId;
+	}else {
+		let label = input.closest('[data-field]')?.querySelector(`label[for="${input.id}"]`);
+		if (label) {
+			label.htmlFor = newId;
 		}
 	}
 

--
Gitblit v1.10.0