Commit a4723528 authored by Ad Schellevis's avatar Ad Schellevis

(mvc) add option to disable "any" in NetworkField type

parent ab386c00
...@@ -57,6 +57,11 @@ class NetworkField extends BaseField ...@@ -57,6 +57,11 @@ class NetworkField extends BaseField
*/ */
protected $internalFieldSeparator = null; protected $internalFieldSeparator = null;
/**
* @var bool wildcard (any) enabled
*/
protected $internalWilcardEnabled = true;
/** /**
* always lowercase / trim networks * always lowercase / trim networks
* @param string $value * @param string $value
...@@ -81,13 +86,26 @@ class NetworkField extends BaseField ...@@ -81,13 +86,26 @@ class NetworkField extends BaseField
/** /**
* if multiple addresses / networks maybe provided at once, set separator. * if multiple addresses / networks maybe provided at once, set separator.
* @param $value separator * @param string $value separator
*/ */
public function setFieldSeparator($value) public function setFieldSeparator($value)
{ {
$this->internalFieldSeparator = $value; $this->internalFieldSeparator = $value;
} }
/**
* enable "any" keyword
* @param string $value Y/N
*/
public function setWildcardEnabled($value)
{
if (strtolower(trim($value)) == 'y') {
$this->internalWilcardEnabled = true;
} else {
$this->internalWilcardEnabled = false;
}
}
/** /**
* retrieve field validators for this field type * retrieve field validators for this field type
* @return array returns Text/regex validator * @return array returns Text/regex validator
...@@ -96,7 +114,7 @@ class NetworkField extends BaseField ...@@ -96,7 +114,7 @@ class NetworkField extends BaseField
{ {
$validators = parent::getValidators(); $validators = parent::getValidators();
if ($this->internalValue != null) { if ($this->internalValue != null) {
if ($this->internalValue != "any") { if ($this->internalValue != "any" || $this->internalWilcardEnabled == false) {
// accept any as target // accept any as target
$validators[] = new NetworkValidator(array( $validators[] = new NetworkValidator(array(
'message' => $this->internalValidationMessage, 'message' => $this->internalValidationMessage,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment