Jake Vanderwerf
2026-02-08 0442e1186ae642c86947d03961fde7d461ba054d
inc/meta/Form.php
@@ -99,7 +99,7 @@
         '<div class="%s" data-field="%s" data-field-type="%s"%s>',
         $classes,
         $name,
         $config['type'],
         str_replace('_', '-', $config['type']),
         $datasets
      );
@@ -109,6 +109,7 @@
      }
      $output .= static::buildHint($config);
      $output .= static::buildCharacterLimit($config);
      $output .= static::buildDescription($name, $config);
      $output .= '</div>';
@@ -179,6 +180,17 @@
            );
         }
         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 buildLabel(string $name, array $config):string
      {
         if (!empty($config['label'])) {
@@ -276,7 +288,7 @@
   protected static function renderText(string $name, mixed $value, array $config): string
   {
      $value = ($value === '') ? ' value="'.esc_attr($value).'"' : '';
      $value = ($value !== '') ? ' value="'.esc_attr($value).'"' : '';
      $input = sprintf(
         '<input type="%s"%s%s />',
         $config['subtype']??'text',
@@ -312,7 +324,7 @@
   {
      $attrs = static::inputAttrs($name, $config);
      $value = ($value === '') ? ' value="'.esc_attr($value).'"' : '';
      $value = ($value !== '') ? ' value="'.esc_attr($value).'"' : '';
      $input = sprintf(
         '<input type="number"%s%s />',
         $value,
@@ -331,7 +343,7 @@
      $attrs = static::inputAttrs($name, $config);
      $value = ($value === '') ? ' value="'.esc_attr($value).'"' : '';
      $value = ($value !== '') ? ' value="'.esc_attr($value).'"' : '';
      $input = sprintf(
         '<div class="quantity">
            <button type="button" class="decrease" title="%s" aria-label="Decrease %s">%s</button>
@@ -354,7 +366,7 @@
   protected static function renderEmail(string $name, mixed $value, array $config): string
   {
      $config['validate'] = 'email';
      $value = ($value === '') ? ' value="'.esc_attr($value).'"' : '';
      $value = ($value !== '') ? ' value="'.esc_attr($value).'"' : '';
      $input = sprintf(
         '<input type="email"%s%s />',
         $value,
@@ -367,7 +379,7 @@
   protected static function renderUrl(string $name, mixed $value, array $config): string
   {
      $config['validate'] = 'url';
      $value = ($value === '') ? ' value="'.esc_attr($value).'"' : '';
      $value = ($value !== '') ? ' value="'.esc_attr($value).'"' : '';
      $input = sprintf(
         '<input type="url"%s%s />',
         $value,
@@ -380,7 +392,7 @@
   protected static function renderTel(string $name, mixed $value, array $config): string
   {
      $config['validate'] = 'phone';
      $value = ($value === '') ? ' value="'.esc_attr($value).'"' : '';
      $value = ($value !== '') ? ' value="'.esc_attr($value).'"' : '';
      $input = sprintf(
         '<input type="tel"%s%s />',
         $value,
@@ -401,7 +413,7 @@
         }
      }
      $value = ($value === '') ? ' value="'.esc_attr($value).'"' : '';
      $value = ($value !== '') ? ' value="'.esc_attr($value).'"' : '';
      $input = sprintf(
         '<input type="date"%s%s />',
         $value,
@@ -413,7 +425,7 @@
   protected static function renderTime(string $name, mixed $value, array $config): string
   {
      $value = ($value === '') ? ' value="'.esc_attr($value).'"' : '';
      $value = ($value !== '') ? ' value="'.esc_attr($value).'"' : '';
      $input = sprintf(
         '<input type="time"%s%s />',
         $value,
@@ -425,7 +437,7 @@
   protected static function renderDatetime(string $name, mixed $value, array $config): string
   {
      $value = ($value === '') ? ' value="'.esc_attr($value).'"' : '';
      $value = ($value !== '') ? ' value="'.esc_attr($value).'"' : '';
      $input = sprintf(
         '<input type="datetime-local"%s%s />',
         $value,
@@ -492,6 +504,8 @@
      $optionsHtml = '';
      if (empty($config['required'])) {
         $optionsHtml .= '<option value="">— Select —</option>';
      } else {
         $optionsHtml .= '<option value="" disabled selected hidden>— Select —</option>';
      }
      foreach ($options as $optValue => $optLabel) {
@@ -538,7 +552,7 @@
            $optValue,
            esc_attr($optValue),
            $checked,
            $name,
            esc_attr($name),
            $optValue,
            esc_html($optLabel)
         );
@@ -564,14 +578,16 @@
      foreach ($options as $optValue => $optLabel) {
         $radios .= sprintf(
            '
                    <input type="radio" name="%s" value="%s"%s />
                    <input type="radio" name="%s" id="%s-%s" value="%s"%s />
            <label class="radio-option" for="%s-%s">
                    <span>%s</span>
                </label>',
            esc_attr($name),
            esc_attr($name),
            $optValue,
            esc_attr($optValue),
            checked($value, $optValue),
            $name,
            esc_attr($name),
            $optValue,
            esc_html($optLabel)
         );
@@ -1443,7 +1459,7 @@
      $input .= sprintf(
         '<button type="button" class="button add-tag">%s<span>%s</span></button></div>',
         jvbIcon('plus'),
         $field['add_label']??'Add'
         $config['add_label']??'Add'
      );
      //Tag Display
@@ -1463,7 +1479,7 @@
   }
      protected static function renderTagItems(array $fields, mixed $value, string $name, string $tagFormat):string
      {
         if ($value === '') {
         if (!$value || $value === '') {
            return '';
         }
         if (is_string($value)) {
@@ -1485,37 +1501,39 @@
         $out = sprintf(
            '<div class="tag-item"%s><span class="tag-label">%s</span>',
            ($index) ? ' data-index="'.$index.'"' : '',
            ($index !== null) ? ' data-index="'.$index.'"' : '',
            $tagText
         );
         foreach ($fields as $fieldName => $fieldConfig) {
            $value = $values[$fieldName]??'';
            $fullName = (!$index) ? $fieldName : sprintf('%s:%s:%s', $name, $index, $fieldName);
            $fullName = ($index === null) ? $fieldName : sprintf('%s:%s:%s', $name, $index, $fieldName);
            $out .= sprintf(
               '<input type="hidden"
               name="%s"
               value="%s"
               data-field="%s"
               data-field-type="%s" />',
                  name="%s"
                  value="%s"
                  data-field="%s"
                  data-field-type="%s"
                  id="%s" />',
               esc_attr($fullName),
               esc_attr($value),
               esc_attr($fieldName),
               esc_attr($fieldConfig['type'])
            );
            $out .= sprintf(
               '<button type="button" class="remove-tag" aria-label="Remove">%s</button>',
               jvbIcon('x')
               esc_attr($fieldConfig['type']),
               esc_attr($fullName)
            );
         }
         $out .= sprintf(
            '<button type="button" class="remove-tag" aria-label="Remove">%s</button>',
            jvbIcon('x')
         );
         $out .='</div>';
         return $out;
      }
         protected static function getTagDisplayText(array $fields, mixed $values, string $tagFormat):string
         {
            if (empty($data)) {
            if (empty($values)) {
               return 'New Item';
            }
@@ -1524,7 +1542,7 @@
                  $firstKey = array_key_first($fields);
                  return $values[$firstKey] ?? 'New Item';
               case 'all_fields':
                  $values = array_filter(array_values($data));
                  $values = array_filter(array_values($values));
                  return implode(', ', $values) ?: 'New Item';
               default:
                  if (strpos($tagFormat, '{') !== false) {