From f16cb88a3218ac7bb32e43f0e0a2542d35c7a01b Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 17 Jun 2026 00:28:16 +0000
Subject: [PATCH] =Working on the Options Meta still. Group fields also needed some changes

---
 inc/meta/Form.php |   34 ++++++++++++++++++++++------------
 1 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/inc/meta/Form.php b/inc/meta/Form.php
index 2cf3f05..dec811f 100644
--- a/inc/meta/Form.php
+++ b/inc/meta/Form.php
@@ -53,12 +53,19 @@
 	/**
 	 * Render complete form from Meta instance
 	 */
-	public static function renderFormFrom(Meta $meta, string $endpoint, array $options = []): string
+	public static function renderFormFrom(Meta $meta, string $endpoint, array $options = [], array $fields = []): string
 	{
 		$id = $options['form-id'] ?? $endpoint;
 		$classes = isset($options['classes']) ? ' class="' . implode(' ', $options['classes']) . '"' : '';
+		$formID = isset($options['showFormID']) && $options['showFormID']!== false;
 
-		$output = '<form id="' . esc_attr($endpoint) . '"' . $classes . ' data-save="' . esc_attr($endpoint) . '" data-form-id="' . esc_attr($id) . '">';
+		$output = sprintf(
+			'<form id="%s"%s data-save="%s"%s>',
+			esc_attr($endpoint),
+			$classes,
+			esc_attr($endpoint),
+			$formID ? ' data-form-id="'.esc_attr($id).'"' : '',
+		);
 
 		if (!empty($options['heading'])) {
 			$output .= '<h2>' . esc_html($options['heading']) . '</h2>';
@@ -70,9 +77,12 @@
 				$output .= '<p>' . esc_html($d) . '</p>';
 			}
 		}
-
-		foreach ($meta->configs() as $name => $config) {
-			$output .= static::render($name, $meta->get($name), $config);
+		error_log('[Form]::renderFormFrom getting fields: '.print_r($fields, true));
+		$allFields = $meta->getAll($fields);
+		error_log('[Form]::renderFormFrom field values: '.print_r($allFields, true));
+		foreach ($allFields as $name => $value) {
+			$config = $meta->config($name);
+			$output .= static::render($name, $value, $config);
 		}
 
 		if (!empty($options['submit'])) {
@@ -556,17 +566,17 @@
 			$checked = in_array($optValue, $values) ? ' checked' : '';
 			$checkboxes .= sprintf(
 				'
-                    <input type="checkbox" name="%s[]" id="%s-%s" value="%s"%s />
+                    <input type="checkbox" name="%s" id="%s-%s" value="%s"%s/>
 				<label class="checkbox-option" for="%s-%s">
                     <span>%s</span>
                 </label>',
 				esc_attr($name),
 				esc_attr($name),
-				$optValue,
+				esc_attr($optValue),
 				esc_attr($optValue),
 				$checked,
 				esc_attr($name),
-				$optValue,
+				esc_attr($optValue),
 				esc_html($optLabel)
 			);
 		}
@@ -1705,7 +1715,7 @@
 
 		foreach ($fields as $fieldName => $fieldConfig) {
 			$fieldValue = $values[$fieldName] ?? '';
-			$fullName = array_key_exists('wrap', $config) ? $fieldName : "{$name}:{$fieldName}";
+			$fullName = "{$name}|{$fieldName}";
 			$output .= static::render($fullName, $fieldValue, $fieldConfig);
 		}
 
@@ -1719,7 +1729,7 @@
 	{
 		return sprintf('<dialog id="jvb-selector" aria-labelledby="modal-title" aria-modal="true">
 				<div class="wrap col">
-					<header class="modal-header">
+					<header class="row">
 						<h3 id="modal-title">Select Taxonomy</h3>
 					</header>
 
@@ -1813,13 +1823,13 @@
 			<template class="selectedTerm">
 				<div class="selected-item row">
 					<span class="item-name"></span>
-					<button type="button" class="remove-term row">%s</button>
+					<button type="button" class="remove-term">%s</button>
 				</div>
 			</template>
 			<template class="termBreadcrumb">
 				<button type="button" class="path-level"></button>
 			</template>',
-			static::search('Search terms', 'search-terms'),
+			str_replace('class="search-container', 'class="open search-container', static::search('Search terms', 'search-terms')),
 			 jvbModalActions(),
 			jvbIcon('plus-square'),
 			jvbIcon('x')

--
Gitblit v1.10.0