Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 7, 2016
Merged

Conversation

phil-davis
Copy link
Contributor

  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.

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.
@phil-davis
Copy link
Contributor Author

Note: This fixes the issue, but it does seem a bit of a kludge to me, jumping out of JS to wrap some PHP test around a single line of JS. But I couldn't think of a way to teach dst_change() to understand the case when 'dst' is empty because the user has selected "Single Host" or "Network" and left the address field blank, vs when the field is blank because this is a new entry being added.

@netgate-git-updates netgate-git-updates merged commit f7405cd into pfsense:master Dec 7, 2016
@phil-davis phil-davis deleted the patch-7 branch December 8, 2016 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants