Project

General

Profile

« Previous | Next » 

Revision 823b7a1a

Added by Phil Davis over 8 years ago

Fix #6224 NAT edit - preserve user selections when input errors

1) Edit a NAT Port Forward rule, change the destination type to "Network", but do not input any network address/mask.
2) Press Save, an input error is reported telling that the network destination address/mask is required - good.
However, the destination type is no longer "Network" - it goes to "xxx address" where "xxx" is the selected interface.

The problem is that JS dst_change() is being called on every page load. That is good when starting a new entry (the Destination gets set to WAN address to match the default interface of WAN), or when starting to edit an existing entry (the code runs without messing anything up). But when data has been $_POSTed and there are input errors, we just want to redisplay whatever the user had selected, not go trying to fix up correlations between fields.
(cherry picked from commit f7405cd2f750e20735aa7b584c0f322e9e0f6cc6)

View differences:

src/usr/local/www/firewall_nat_edit.php
1269 1269

  
1270 1270
	hideSource(!srcenabled);
1271 1271
	ext_change();
1272
<?php
1273
if (!$_POST) {
1274
?>
1272 1275
	dst_change($('#interface').val(),'<?=htmlspecialchars($pconfig['interface'])?>','<?=htmlspecialchars($pconfig['dst'])?>');
1276
<?php
1277
}
1278
?>
1273 1279
	iface_old = $('#interface').val();
1274 1280
	typesel_change();
1275 1281
	proto_change();

Also available in: Unified diff