Skip to content

Commit

Permalink
Allow toggling to preview context in People form
Browse files Browse the repository at this point in the history
Test case for wintercms/winter#1065
  • Loading branch information
bennothommo committed Aug 28, 2024
1 parent ee85b44 commit 77e64c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 9 additions & 4 deletions controllers/people/_form_toggle.htm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
$uriPrefix = $formModel->exists
? 'winter/test/people/update/'.$formModel->id
: 'winter/test/people/create';
$uriPrefix = ($formContext === 'create')
? 'winter/test/people/create'
: 'winter/test/people/' . $formContext . '/' . $formModel->id;
?>
<div class="callout callout-warning no-subheader">
<div class="header">
Expand All @@ -10,9 +10,14 @@ <h3>Alternate views</h3>
</div>
<div class="content">
<ul>
<?php if ($formContext === 'preview'): ?>
<li><a href="<?= Backend::url('winter/test/people/update/' . $formModel->id) ?>">Update Context</a></li>
<?php elseif ($formContext === 'update'): ?>
<li><a href="<?= Backend::url('winter/test/people/preview/' . $formModel->id) ?>">Preview Context</a></li>
<?php endif ?>
<li><a href="<?= Backend::url($uriPrefix.'/recordfinder') ?>">Record Finder</a></li>
<li><a href="<?= Backend::url($uriPrefix.'/relationcontroller') ?>">Relation Controller</a></li>
<li><a href="<?= Backend::url($uriPrefix.'/proxyfields') ?>">Proxy Fields</a></li>
</ul>
</div>
</div>
</div>
2 changes: 2 additions & 0 deletions controllers/people/preview.htm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

<?php if (!$this->fatalError): ?>

<?= $this->makePartial('form_toggle') ?>

<div class="layout-item stretch layout-column form-preview">
<?= $this->formRenderPreview() ?>
</div>
Expand Down

0 comments on commit 77e64c2

Please sign in to comment.