Fix settings page subforms (so all the fields show for the cache)

This commit is contained in:
Timothy Warren 2020-05-08 19:16:04 -04:00
parent e724f885c8
commit 3ecccb6ad8
3 changed files with 33 additions and 8 deletions

View File

@ -0,0 +1,5 @@
<article>
<label for="<?= $fieldName ?>"><?= $field['title'] ?></label><br />
<small><?= $field['description'] ?></small><br />
<?= $helper->field($fieldName, $field); ?>
</article>

View File

@ -6,19 +6,19 @@
?> ?>
<?php foreach ($fields as $name => $field): ?> <?php foreach ($fields as $name => $field): ?>
<?php $fieldname = ($section === 'config' || $nestedPrefix !== 'config') ? "{$nestedPrefix}[{$name}]" : "{$nestedPrefix}[{$section}][{$name}]"; ?> <?php
$fieldName = ($section === 'config' || $nestedPrefix !== 'config')
? "{$nestedPrefix}[{$name}]"
: "{$nestedPrefix}[{$section}][{$name}]";
?>
<?php if ($field['type'] === 'subfield'): ?> <?php if ($field['type'] === 'subfield'): ?>
<section> <section>
<h4><?= $field['title'] ?></h4> <h4><?= $field['title'] ?></h4>
<?php include_once '_form.php'; ?> <?php include '_subfield.php'; ?>
</section> </section>
<?php elseif ( ! empty($field['display'])): ?> <?php elseif ( ! empty($field['display'])): ?>
<article> <?php include '_field.php' ?>
<label for="<?= $fieldname ?>"><?= $field['title'] ?></label><br />
<small><?= $field['description'] ?></small><br />
<?= $helper->field($fieldname, $field); ?>
</article>
<?php else: ?> <?php else: ?>
<?php $hiddenFields[] = $helper->field($fieldname, $field); ?> <?php $hiddenFields[] = $helper->field($fieldName, $field); ?>
<?php endif ?> <?php endif ?>
<?php endforeach ?> <?php endforeach ?>

View File

@ -0,0 +1,20 @@
<?php
// Higher scoped variables:
// $field
// $fields
// $hiddenFields
// $nestedPrefix
?>
<?php foreach ($field['fields'] as $name => $field): ?>
<?php
$fieldName = ($section === 'config' || $nestedPrefix !== 'config')
? "{$nestedPrefix}[{$name}]"
: "{$nestedPrefix}[{$section}][{$name}]";
?>
<?php if ( ! empty($field['display'])): ?>
<?php include '_field.php' ?>
<?php else: ?>
<?php $hiddenFields[] = $helper->field($fieldName, $field); ?>
<?php endif ?>
<?php endforeach ?>