mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 01:24:38 +00:00
(mvc) add option to disable "any" in NetworkField type
This commit is contained in:
parent
ab386c0023
commit
a4723528c0
@ -57,6 +57,11 @@ class NetworkField extends BaseField
|
||||
*/
|
||||
protected $internalFieldSeparator = null;
|
||||
|
||||
/**
|
||||
* @var bool wildcard (any) enabled
|
||||
*/
|
||||
protected $internalWilcardEnabled = true;
|
||||
|
||||
/**
|
||||
* always lowercase / trim networks
|
||||
* @param string $value
|
||||
@ -81,13 +86,26 @@ class NetworkField extends BaseField
|
||||
|
||||
/**
|
||||
* if multiple addresses / networks maybe provided at once, set separator.
|
||||
* @param $value separator
|
||||
* @param string $value separator
|
||||
*/
|
||||
public function setFieldSeparator($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
|
||||
* @return array returns Text/regex validator
|
||||
@ -96,7 +114,7 @@ class NetworkField extends BaseField
|
||||
{
|
||||
$validators = parent::getValidators();
|
||||
if ($this->internalValue != null) {
|
||||
if ($this->internalValue != "any") {
|
||||
if ($this->internalValue != "any" || $this->internalWilcardEnabled == false) {
|
||||
// accept any as target
|
||||
$validators[] = new NetworkValidator(array(
|
||||
'message' => $this->internalValidationMessage,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user