From bf69b2c2daeb2d5c1f9b1b3dfe99bfb62a739a9a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 10 Feb 2026 02:42:15 +0000
Subject: [PATCH] =more CRUDSkeleton
---
inc/meta/Form.php | 43 +++++++++++++++++++++++++------------------
1 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/inc/meta/Form.php b/inc/meta/Form.php
index e2b4a45..2ad8dc9 100644
--- a/inc/meta/Form.php
+++ b/inc/meta/Form.php
@@ -87,7 +87,7 @@
// Helper Methods
// ─────────────────────────────────────────────────────────────
- protected static function fieldWrap(string $name, string $content, array $config): string
+ public static function fieldWrap(string $name, string $content, array $config): string
{
$classes = static::buildClasses($config);
$datasets = static::buildDatasets($config);
@@ -103,13 +103,13 @@
$datasets
);
+ $output .= static::buildCharacterLimit($config);
$output .= static::buildLabel($name, $config);
if (!array_key_exists('skipInput', $config)) {
$output .= static::buildInput($content);
}
$output .= static::buildHint($config);
- $output .= static::buildCharacterLimit($config);
$output .= static::buildDescription($name, $config);
$output .= '</div>';
@@ -180,16 +180,20 @@
);
}
- protected static function buildCharacterLimit(array $config): string
- {
- if (empty($config['data']['limit'])) {
- return '';
- }
- return sprintf(
- '<span class="char-limit"><span class="current">0</span> / <span class="limit">%s</span></span>',
- esc_html($config['data']['limit'])
- );
- }
+ protected static function buildCharacterLimit(array $config): string
+ {
+ $type = $config['type'] ?? 'text';
+ if (in_array($type, ['upload', 'gallery', 'selector'])) {
+ return '';
+ }
+ if (empty($config['maxlength'])) {
+ return '';
+ }
+ return sprintf(
+ '<span class="char-limit"><span class="current">0</span> / <span class="limit">%s</span></span>',
+ esc_html($config['maxlength'])
+ );
+ }
protected static function buildLabel(string $name, array $config):string
{
@@ -204,7 +208,7 @@
return '';
}
- protected static function buildInput(string $content):string
+ public static function buildInput(string $content):string
{
return sprintf(
'<div class="field-input-wrapper">
@@ -512,7 +516,7 @@
$optionsHtml .= sprintf(
'<option value="%s"%s>%s</option>',
esc_attr($optValue),
- selected($value, $optValue),
+ selected($value, $optValue, false),
esc_html($optLabel)
);
}
@@ -586,7 +590,7 @@
esc_attr($name),
$optValue,
esc_attr($optValue),
- checked($value, $optValue),
+ checked($value, $optValue,false),
esc_attr($name),
$optValue,
esc_html($optLabel)
@@ -663,7 +667,7 @@
?? str_replace('_', ' ',$config['content']);
}
if ($config['limit'] > 0) {
- $config['data']['limit'] = $config['limit'];
+ $config['data']['max-files'] = $config['limit'];
}
$attachmentIds = static::parseIds($value);
@@ -709,7 +713,8 @@
$input .= '<div class="file-error"></div>';
$input .= jvbRenderProgressBar('', false, true, true);
- $input .= '</div>';
+
+ $input .= '</div>'; // closes .file-upload-wrapper
if ($config['destination'] === 'post_group') {
$input .= static::renderUploadGroupAreaStart($config, $plural, $singular);
@@ -720,6 +725,7 @@
$input .= static::renderUploadGroupAreaEnd($config, $plural, $singular);
}
+ $input .= '</div>'; // closes .file-upload-container
unset($config['description']);
unset($config['label']);
return static::fieldWrap($name, $input, $config);
@@ -1648,12 +1654,13 @@
foreach ($fields as $fieldName => $fieldConfig) {
$fieldValue = $values[$fieldName] ?? '';
- $fullName = "{$name}:{$fieldName}";
+ $fullName = array_key_exists('wrap', $config) ? $fieldName : "{$name}:{$fieldName}";
$output .= static::render($fullName, $fieldValue, $fieldConfig);
}
$output .= sprintf('</%s>', esc_attr($wrapper));
+ unset($config['label']);
return static::fieldWrap($name, $output, $config);
}
--
Gitblit v1.10.0