Fix saving from the function modal. Put action in the post variables and change the action to save instead of function.

pull/3621/head
Isaac Connor 2022-10-12 21:23:58 -04:00
parent 5ae47c8671
commit 20ebbc3c58
2 changed files with 5 additions and 2 deletions

View File

@ -24,12 +24,13 @@ if ( !canEdit('Monitors') ) return;
<div id="modalFunction" class="modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<form id="function_form" action="?view=function&action=function" method="post">
<form id="function_form" action="?view=function" method="post">
<?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="mid"/>
<input type="hidden" name="action" value="save"/>
<div class="modal-header">
<h5 class="modal-title"><?php echo translate('Function') ?> - <span id="function_monitor_name"></span></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">

View File

@ -30,7 +30,7 @@ if ( !canEdit('Monitors', $mid) ) {
return;
}
if ( $action == 'function' ) {
if ($action == 'save') {
$monitor = new ZM\Monitor($mid);
if ( !$monitor->Id() ) {
ZM\Error("Monitor not found with Id=$mid");
@ -53,6 +53,8 @@ if ( $action == 'function' ) {
} else {
ZM\Debug('No change to function, not doing anything.');
}
} else {
ZM\Error("Unsupported action $action on view=function.");
} // end if action
$redirect = '?view=console';
?>