Skip to content

Conditionally include a 'Cancel' button next to 'Save' (CFM-31) #236

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -48,6 +48,12 @@ if (empty($attribute_type)) {
$hidden = [
'attribute' => $attribute_type
];

/*
* Include a "cancel" button next to the "save" button
*/

$this->set('vv_include_cancel',true);

/*
* Common Fields for all attributes
Expand Down
5 changes: 5 additions & 0 deletions app/templates/element/form/submit.php
Expand Up @@ -37,6 +37,11 @@
</div>
<div class="field-info">
<?= $this->Form->submit($label) ?>
<?php if(!empty($vv_include_cancel)): ?>
<button type="button" onclick="history.back()" class="btn btn-cancel">
<?= __d('operation','cancel') ?>
</button>
<?php endif; ?>
</div>
</div>
</li>
Expand Down
12 changes: 11 additions & 1 deletion app/webroot/css/co-base.css
Expand Up @@ -1454,6 +1454,10 @@ ul.form-list .not-set {
ul.form-list li.fields-submit .required {
font-style: italic;
}
ul.form-list li.fields-submit .field-info {
display: flex;
gap: 1em;
}
ul.field-children {
margin: 0.5em;
padding: 0;
Expand Down Expand Up @@ -2156,10 +2160,12 @@ button, .btn, .btn:hover {
.btn-secondary,
.btn-tertiary,
.btn-default,
.btn-cancel,
.btn-primary:active,
.btn-secondary:active,
.btn-tertiary:active,
.btn-default:active {
.btn-default:active,
.btn-cancel:active {
box-shadow: 0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.2),0 1px 5px 0 rgba(0,0,0,.12);
}
.btn-primary:hover,
Expand All @@ -2171,6 +2177,10 @@ button, .btn, .btn:hover {
border-color: var(--cmg-color-btn-bg-002);
text-decoration: none !important;
}
.btn-cancel:hover {
background-color: var(--cmg-color-bg-009);
text-decoration: none !important;
}
.btn-primary.disabled,
.btn-primary:disabled {
color: var(--cmg-color-txt-inverse);
Expand Down