Skip to content

Commit

Permalink
update storage modal to fix buttons not being in form. Also remove du…
Browse files Browse the repository at this point in the history
…plicate view field and make button action be save instead of Save. Fixes #3605
  • Loading branch information
Isaac Connor committed Oct 7, 2022
1 parent eed60e7 commit 371f1ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
15 changes: 7 additions & 8 deletions web/ajax/modals/storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

$null = '';
$checked = 'checked="checked"';
$sid = $_REQUEST['id'];
$sid = validInt($_REQUEST['id']);

if ( !canEdit('System') ) return;
if (!canEdit('System')) return;

require_once('includes/Server.php');
require_once('includes/Storage.php');

if ( $_REQUEST['id'] ) {
if ( !($newStorage = ZM\Storage::find_one(array('Id'=>$sid)) ) ) {
if ($_REQUEST['id']) {
if (!($newStorage = ZM\Storage::find_one(array('Id'=>$sid)))) {
// Perhaps do something different here, rather than return nothing
return;
}
Expand Down Expand Up @@ -46,15 +46,14 @@
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form id="storageModalForm" name="contentForm" method="post" action="?view=storage&action=save" class="validateFormOnSubmit">
<?php
// We have to manually insert the csrf key into the form when using a modal generated via ajax call
echo getCSRFinputHTML();
?>
<input type="hidden" name="view" value="storage"/>
<input type="hidden" name="object" value="storage"/>
<input type="hidden" name="id" value="<?php echo validHtmlStr($sid) ?>"/>
<div class="modal-body">
<div class="table-responsive">
<table class="major table table-sm">
<tbody>
Expand Down Expand Up @@ -102,10 +101,10 @@
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button name="action" id="storageSubmitBtn" type="submit" class="btn btn-primary" value="Save"><?php echo translate('Save') ?></button>
<button name="action" id="storageSubmitBtn" type="submit" class="btn btn-primary" value="save"><?php echo translate('Save') ?></button>
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo translate('Cancel') ?></button>
</div>
</form>
Expand Down
4 changes: 2 additions & 2 deletions web/includes/actions/storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
return;
}

if ( $action == 'save' ) {
if ($action == 'save') {
$storage = new ZM\Storage($_REQUEST['id']);

$changes = $storage->changes($_REQUEST['newStorage']);

if ( count($changes) ) {
if (count($changes)) {
$storage->save($changes);
$refreshParent = true;
}
Expand Down

0 comments on commit 371f1ad

Please sign in to comment.