From 0113d2e9c9ff34a6ffb10707cc76d34b67a0c367 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Mon, 19 Jan 2026 16:29:41 +0000
Subject: [PATCH] =Refactored window.getTemplate into a full templating class window.jvbTemplates. Refactored CRUD.js, UploadManager.js, FormController.js, PopulateForm.js with that in mind
---
inc/meta/MetaForm.php | 25 ++++++++++++++++++++-----
1 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/inc/meta/MetaForm.php b/inc/meta/MetaForm.php
index 2324496..5225f9b 100644
--- a/inc/meta/MetaForm.php
+++ b/inc/meta/MetaForm.php
@@ -212,6 +212,7 @@
<div class="field <?= esc_attr($field['type']) ?> <?= esc_attr($name) ?>"
<?= $conditional ?>
data-field="<?= esc_attr($name) ?>"
+ data-field-type="<?=esc_attr($field['type'])?>"
<?= $validationAttrs ?>>
<?php $this->renderLabel($name, $field); ?>
@@ -366,6 +367,7 @@
<div class="field <?= esc_attr($field['type']) ?> <?= esc_attr($name) ?>"
<?= $conditional ?>
data-field="<?= esc_attr($name) ?>"
+ data-field-type="<?=esc_attr($field['type'])?>"
<?= $validationAttrs ?>>
<?php $this->renderLabel($name, $field); ?>
@@ -424,6 +426,7 @@
<div class="field <?= esc_attr($field['type']) ?> <?= esc_attr($name) ?> row"
<?= $conditional ?>
data-field="<?= esc_attr($name) ?>"
+ data-field-type="<?=esc_attr($field['type'])?>"
<?= $validationAttrs ?>>
<?php $this->renderLabel($name, $field); ?>
@@ -474,6 +477,7 @@
<div class="field <?= esc_attr($field['type']) ?> <?= esc_attr($name) ?>"
<?= $conditional ?>
data-field="<?= esc_attr($name) ?>"
+ data-field-type="<?=esc_attr($field['type'])?>"
<?= $validationAttrs ?>>
<?php $this->renderLabel($name, $field); ?>
@@ -514,6 +518,7 @@
<div class="field <?= esc_attr($field['type']) ?> <?= esc_attr($name) ?>"
<?= $conditional ?>
data-field="<?= esc_attr($name) ?>"
+ data-field-type="<?=esc_attr($field['type'])?>"
<?= $validationAttrs ?>>
<fieldset>
@@ -559,6 +564,7 @@
<div class="field <?= esc_attr($field['type']) ?> <?= esc_attr($name) ?>"
<?= $conditional ?>
data-field="<?= esc_attr($name) ?>"
+ data-field-type="<?=esc_attr($field['type'])?>"
<?= $validationAttrs ?>>
<fieldset>
@@ -600,6 +606,7 @@
<div class="field true-false <?= esc_attr($name) ?> row btw"
<?= $conditional ?>
data-field="<?= esc_attr($name) ?>"
+ data-field-type="<?=esc_attr($field['type'])?>"
<?= $validationAttrs ?>>
<label class="toggle-switch row" <?= $describedBy ?>>
@@ -642,6 +649,7 @@
?>
<div class="field repeater <?=$name?>"
data-field="<?= esc_attr($name); ?>"
+ data-field-type="<?=esc_attr($field['type'])?>"
<?= $describedBy ?>
<?= $row_label ? 'data-label="' . esc_attr($row_label) . '"' : ''; ?>
<?=$conditional?>>
@@ -663,7 +671,7 @@
?>
</div>
- <template class="<?=uniqid('repeaterTemplate')?>">
+ <template class="<?=uniqid('repeaterRow')?>">
<?php $this->renderRepeaterRow($field['fields'], array(), '', '', $rowTitle); ?>
</template>
@@ -756,7 +764,8 @@
?>
<<?= $fieldset?> class="field group <?= esc_attr($name) ?>"
<?= $conditional ?>
- data-field="<?= esc_attr($name) ?>"
+ data-field="<?= esc_attr($name) ?>"
+ data-field-type="<?=esc_attr($field['type'])?>"
<?= $validationAttrs ?>
<?= $describedBy ?>>
<<?=$legend?>><?= esc_html($field['label']) ?></<?=$legend?>>
@@ -880,6 +889,8 @@
}
?>
<div class="field upload <?= esc_attr($name) ?>"
+ data-field="<?=esc_attr($name)?>"
+ data-field-type="upload"
<?= $dataAttrString ?>
<?= $conditional ?>>
@@ -1411,7 +1422,8 @@
<div class="field selector <?= esc_attr($type) ?> <?= esc_attr($name) ?>"
<?= $conditional ?>
data-field="<?= esc_attr($name) ?>"
- data-type="selector" data-subtype="<?= esc_attr($type)?>"
+ data-field-type="selector"
+ data-type="<?=esc_attr($field['type'])?>"
<?= $validationAttrs ?>
<?= $describedBy ?>>
@@ -1477,6 +1489,7 @@
<div class="field location <?= esc_attr($field_id) ?>"
data-field="<?= esc_attr($field_id) ?>"
+ data-field-type="<?=esc_attr($field['type'])?>"
data-location-field-init="<?= $json_config ?>"<?=$describedBy?>>
<?php
@@ -1639,6 +1652,7 @@
?>
<div class="field tag-list <?= esc_attr($name) ?>"
data-field="<?= esc_attr($name) ?>"
+ data-field-type="<?=esc_attr($field['type'])?>"
data-tag-format="<?= esc_attr($tagFormat) ?>"
<?= $describedBy ?>
<?= $conditional ?>
@@ -1681,7 +1695,7 @@
</div>
<!-- Template for new tags -->
- <template class="tag-template">
+ <template class="<?=uniqid('tagListItem')?>">
<?php $this->renderTagItem($field['fields'], [], '', $name, $tagFormat); ?>
</template>
@@ -1715,7 +1729,8 @@
<input type="hidden"
name="<?= esc_attr($full_name) ?>"
value="<?= esc_attr($value) ?>"
- data-field="<?= esc_attr($field_name) ?>" />
+ data-field="<?= esc_attr($field_name) ?>"
+ data-field-type="<?=esc_attr($field_config['type'])?>" />
<?php endforeach; ?>
<button type="button" class="remove-tag" aria-label="Remove">
--
Gitblit v1.10.0