Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
e287e106
Commit
e287e106
authored
May 28, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(mvc) improve ModelRelation validation
parent
212a5e48
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
16 deletions
+7
-16
ModelRelationField.php
...pp/models/OPNsense/Base/FieldTypes/ModelRelationField.php
+7
-16
No files found.
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/ModelRelationField.php
View file @
e287e106
...
...
@@ -29,7 +29,7 @@
*/
namespace
OPNsense\Base\FieldTypes
;
use
Phalcon\Validation\Validator\
Regex
;
use
Phalcon\Validation\Validator\
InclusionIn
;
/**
* Class ModelRelationField defines a relation to another entity within the model, acts like a select item.
...
...
@@ -102,25 +102,16 @@ class ModelRelationField extends BaseField
*/
public
function
getValidators
()
{
// build validation mask
$validationMask
=
'('
;
$countid
=
0
;
foreach
(
self
::
$internalOptionList
as
$key
=>
$value
)
{
if
(
$countid
>
0
)
{
$validationMask
.=
'|'
;
}
$validationMask
.=
$key
;
$countid
++
;
}
$validationMask
.=
')'
;
if
(
$this
->
internalValidationMessage
==
null
)
{
$msg
=
"option not in list"
;
$msg
=
"option not in list"
;
}
else
{
$msg
=
$this
->
internalValidationMessage
;
}
if
((
$this
->
internalIsRequired
==
true
||
$this
->
internalValue
!=
null
)
&&
$validationMask
!=
null
)
{
return
array
(
new
Regex
(
array
(
'message'
=>
$msg
,
'pattern'
=>
trim
(
$validationMask
))));
if
((
$this
->
internalIsRequired
==
true
||
$this
->
internalValue
!=
null
)
&&
count
(
self
::
$internalOptionList
)
>
0
)
{
return
array
(
new
InclusionIn
(
array
(
'message'
=>
$msg
,
'domain'
=>
array_keys
(
self
::
$internalOptionList
))));
}
else
{
// empty field and not required, skip this validation.
return
array
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment