diff options
author | Steve Beaver <sbeaver@netgate.com> | 2017-01-23 11:50:39 -0500 |
---|---|---|
committer | Steve Beaver <sbeaver@netgate.com> | 2017-01-23 11:50:39 -0500 |
commit | 81fd21019cd0de8300fa0480cff1973d58d28e03 (patch) | |
tree | c4437385053fb6a1d919e84a514afd01e9313117 /src/usr/local | |
parent | 07432828183dd1ca30d242b0a6ab58297bfb2b18 (diff) | |
download | pfsense-81fd21019cd0de8300fa0480cff1973d58d28e03.zip pfsense-81fd21019cd0de8300fa0480cff1973d58d28e03.tar.gz |
Fixed #6958
Diffstat (limited to 'src/usr/local')
-rw-r--r-- | src/usr/local/www/services_dhcp_relay.php | 76 |
1 files changed, 47 insertions, 29 deletions
diff --git a/src/usr/local/www/services_dhcp_relay.php b/src/usr/local/www/services_dhcp_relay.php index fc8e367..952e3e8 100644 --- a/src/usr/local/www/services_dhcp_relay.php +++ b/src/usr/local/www/services_dhcp_relay.php @@ -74,32 +74,32 @@ if ($_POST) { /* input validation */ if ($_POST['enable']) { - $reqdfields = explode(" ", "server interface"); - $reqdfieldsn = array(gettext("Destination Server"), gettext("Interface")); + $reqdfields = explode(" ", "interface"); + $reqdfieldsn = array(gettext("Interface")); do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); $svrlist = ''; - if ($_POST['server']) { - foreach ($_POST['server'] as $checksrv => $srv) { - if (!empty($srv[0])) { // Filter out any empties - if (!is_ipaddrv4($srv[0])) { - $input_errors[] = sprintf(gettext("Destination Server IP address %s is not a valid IPv4 address."), $srv[0]); + for ($idx=0; $idx<count($_POST); $idx++) { + if ($_POST['server' . $idx]) { + if (!empty($_POST['server' . $idx])) { // Filter out any empties + if (!is_ipaddrv4($_POST['server' . $idx])) { + $input_errors[] = sprintf(gettext("Destination Server IP address %s is not a valid IPv4 address."), $_POST['server' . $idx]); } if (!empty($svrlist)) { $svrlist .= ','; } - $svrlist .= $srv[0]; + $svrlist .= $_POST['server' . $idx]; } } + } - // Check that the user input something in one of the Destination Server fields - if (empty($svrlist)) { - $input_errors[] = gettext("At least one Destination Server IP address must be specified."); - } + // Check that the user input something in one of the Destination Server fields + if (empty($svrlist)) { + $input_errors[] = gettext("At least one Destination Server IP address must be specified."); } } @@ -152,7 +152,7 @@ $section->addInput(new Form_Checkbox( $section->addInput(new Form_Select( 'interface', - 'Interface(s)', + '*Interface(s)', $pconfig['interface'], $iflist, true @@ -168,32 +168,50 @@ $section->addInput(new Form_Checkbox( [$g['product_name']] ); -//Small function to prevent duplicate code -function createDestinationServerInputGroup($value = null) { - $group = new Form_Group('Destination server'); + +$counter = 0; +foreach (explode(',', $pconfig['server']) as $server) { + $group = new Form_Group($counter == 0 ? gettext("*Destination server"):''); + $group->addClass('repeatable'); $group->add(new Form_IpAddress( - 'server', + 'server' . $counter, 'Destination server', - $value, + $server, 'V4' ))->setWidth(4) - ->setHelp('This is the IPv4 address of the server to which DHCP requests are relayed.') - ->setIsRepeated(); + ->setHelp('This is the IPv4 address of the server to which DHCP requests are relayed.'); - $group->enableDuplication(null, true); // Buttons are in-line with the input - return $group; -} + $group->add(new Form_Button( + 'deleterow' . $counter, + 'Delete', + null, + 'fa-trash' + ))->addClass('btn-warning'); -if (!isset($pconfig['server'])) { - $section->add(createDestinationServerInputGroup()); -} else { - foreach (explode(',', $pconfig['server']) as $server) { - $section->add(createDestinationServerInputGroup($server)); - } + $section->add($group); + $counter++; } $form->add($section); + +$form->addGlobal(new Form_Button( + 'addrow', + "Add server", + null, + 'fa-plus' +))->addClass('btn-success addbtn'); + print $form; +?> +<script type="text/javascript"> +//<![CDATA[ + events.push(function() { + // Suppress "Delete row" button if there are fewer than two rows + checkLastRow(); + }); +//]]> +</script> +<?php include("foot.inc"); |