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 |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/inc/meta/Form.php b/inc/meta/Form.php
index 8b7b414..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);
 		}
 

--
Gitblit v1.10.0