From 726756def3cb4a193b68ffe38f115ecfd0ba677c Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 16 Apr 2017 15:06:21 +0545 Subject: Remember original alias name on edit input errors (cherry picked from commit 1271754326fe648093204296652398b1edd24912) --- src/usr/local/www/firewall_aliases_edit.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/usr/local/www') diff --git a/src/usr/local/www/firewall_aliases_edit.php b/src/usr/local/www/firewall_aliases_edit.php index 446c1d0..db84d15 100644 --- a/src/usr/local/www/firewall_aliases_edit.php +++ b/src/usr/local/www/firewall_aliases_edit.php @@ -92,10 +92,6 @@ if (!is_array($config['aliases']['alias'])) { } $a_aliases = &$config['aliases']['alias']; -if ($_POST) { - $origname = $_POST['origname']; -} - // Debugging if ($debug) { unlink_if_exists("{$g['tmp_path']}/alias_rename_log.txt"); @@ -159,6 +155,14 @@ if (isset($id) && $a_aliases[$id]) { } } +if ($_POST['save']) { + // Remember the original name on an attempt to save + $origname = $_POST['origname']; +} else { + // Set the original name on edit (or add, when this will be blank) + $origname = $pconfig['name']; +} + $tab = $_REQUEST['tab']; if (empty($tab)) { @@ -502,7 +506,7 @@ if ($_POST) { /* Check to see if alias name needs to be * renamed on referenced rules and such */ - if ($_POST['name'] <> $_POST['origname']) { + if ($_POST['name'] <> $origname) { update_alias_name($_POST['name'], $origname); } @@ -649,7 +653,7 @@ $form->addGlobal(new Form_Input( 'origname', null, 'hidden', - $pconfig['name'] + $origname )); if (isset($id) && $a_aliases[$id]) { -- cgit v1.1