From b3005955c1e564ec907b5c9c19141d9fa978595f Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 22 Sep 2023 13:08:13 +0200 Subject: [PATCH] mvc: HostnameField validation message --- .../Base/FieldTypes/HostnameField.php | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/HostnameField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/HostnameField.php index 18809a57f..f6704ffdb 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/HostnameField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/HostnameField.php @@ -41,11 +41,6 @@ class HostnameField extends BaseField */ protected $internalIsContainer = false; - /** - * @var string default validation message string - */ - protected $internalValidationMessage = "please specify a valid address (IPv4/IPv6) or hostname"; - /** * @var null when multiple values could be provided at once, specify the split character */ @@ -158,6 +153,14 @@ class HostnameField extends BaseField } } + /** + * {@inheritdoc} + */ + protected function defaultValidationMessage() + { + return gettext('Please specify a valid IP address or hostname.'); + } + /** * retrieve field validators for this field type * @return array returns Text/regex validator @@ -166,14 +169,14 @@ class HostnameField extends BaseField { $validators = parent::getValidators(); if ($this->internalValue != null) { - $validators[] = new HostValidator(array( - 'message' => $this->internalValidationMessage, + $validators[] = new HostValidator([ + 'message' => $this->getValidationMessage(), 'split' => $this->internalFieldSeparator, 'allowip' => $this->internalIpAllowed, 'hostwildcard' => $this->internalHostWildcardAllowed, 'fqdnwildcard' => $this->internalFqdnWildcardAllowed, - 'zoneroot' => $this->internalZoneRootAllowed - )); + 'zoneroot' => $this->internalZoneRootAllowed, + ]); } return $validators; }