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

---
 inc/meta/MetaForm.php |   35 ++++++++++++++++++-----------------
 1 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/inc/meta/MetaForm.php b/inc/meta/MetaForm.php
index bfb93eb..ea8f614 100644
--- a/inc/meta/MetaForm.php
+++ b/inc/meta/MetaForm.php
@@ -202,6 +202,7 @@
 		$validationAttrs = $this->buildValidationAttributes($field);
 		$conditional = array_key_exists('condition', $field) ? $this->handleConditionalField($field) : '';
 
+		$pattern = array_key_exists('pattern', $field) ? $field['pattern'] : '';
 		$customData = '';
 		if (array_key_exists('data', $field) && !empty($field['data'])) {
 			foreach ($field['data'] as $key => $v) {
@@ -225,6 +226,7 @@
 					value="<?= esc_attr($data['value']) ?>"
 					<?= $inputAttrs ?>
 					<?= $customData?>
+					<?= $pattern?>
 				>
 				<span class="validation-icon success" hidden aria-hidden="true">
                     <?= jvbIcon('check-circle') ?>
@@ -789,7 +791,9 @@
 	{
 		foreach ($field['fields'] as $field_name => $config) {
 			// Set the group context for proper field naming
-			$config['group'] = $groupName;
+			if (!array_key_exists('wrap', $field) || $field['wrap'] !== 'details') {
+				$config['group'] = $groupName;
+			}
 
 			// Get the value for this specific field
 			$field_value = $values[$field_name] ?? '';
@@ -843,7 +847,7 @@
 
 		// Build accept attribute for input
 		$acceptExtensions = $this->getMimeExtensions($acceptedTypes);
-		$acceptAttr = implode(',', $acceptExtensions);
+		$acceptAttr = implode(',', $acceptedTypes);
 
 		// Determine field attributes
 		$subtype = $config['subtype'] ?? 'image';
@@ -1138,15 +1142,12 @@
 				<summary class="row btw"><?=jvbIcon('pencil-simple')?><span>Edit Info</span></summary>
 
 				<?php
-				$fields = array_key_exists('fields', $config) ? $config['fields'] : [];
 
-				// Only add image_data if not already provided
-				if (!array_key_exists('image_data', $fields)) {
-					$fields['image_data'] = [
-						'type'   => 'group',
-						'wrap'   => 'details',
-						'label'  => 'Image Info',
-						'hint'   => 'These will be automatically generated if left blank.',
+				$fields = [
+					'image_data' => [
+						'type'	=> 'group',
+						'wrap'	=> 'details',
+						'label'	=> 'Image Fields',
 						'fields' => [
 							'image-title'.$addID => [
 								'type'  => 'text',
@@ -1168,9 +1169,9 @@
 								'data'  => $dataID
 							]
 						]
-					];
-				}
-
+					]
+				];
+				$fields = array_key_exists('fields', $config) ? array_merge($fields, $config['fields']) : $fields;
 				$meta = new MetaManager($id);
 				foreach ($fields as $field => $config) {
 					$meta->render('form', $field, $config);
@@ -1594,11 +1595,11 @@
 
 		// Default types based on subtype
 		$defaults = [
-			'image' => ['image/jpeg', 'image/png', 'image/gif', 'image/webp'],
-			'video' => ['video/mp4', 'video/webm', 'video/ogg'],
-			'document' => ['application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
-			'any' => ['image/*', 'video/*', 'application/pdf']
+			'image' => ['image/*'],
+			'video' => ['video/*'],
+			'document' => ['application/pdf', 'application/msword', 'application/vnd.ms-excel', 'text/plain', '.odt','application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
 		];
+		$defaults['any'] = array_merge($defaults['image'], $defaults['video'], $defaults['document']);
 
 		return $defaults[$config['subtype']] ?? $defaults['image'];
 	}

--
Gitblit v1.10.0