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
4f871e40
Commit
4f871e40
authored
Mar 30, 2016
by
Frank Wall
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support multiple values in ModelRelationField, fixes #868
parent
95522e09
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
9 deletions
+24
-9
ModelRelationField.php
...pp/models/OPNsense/Base/FieldTypes/ModelRelationField.php
+24
-9
No files found.
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/ModelRelationField.php
View file @
4f871e40
...
...
@@ -30,6 +30,7 @@
namespace
OPNsense\Base\FieldTypes
;
use
Phalcon\Validation\Validator\InclusionIn
;
use
OPNsense\Base\Validators\CsvListValidator
;
/**
* Class ModelRelationField defines a relation to another entity within the model, acts like a select item.
...
...
@@ -42,6 +43,11 @@ class ModelRelationField extends BaseField
*/
protected
$internalIsContainer
=
false
;
/**
* @var bool field may contain multiple data nodes at once
*/
private
$internalMultiSelect
=
false
;
/**
* @var string default validation message string
*/
...
...
@@ -107,6 +113,19 @@ class ModelRelationField extends BaseField
}
}
/**
* select if multiple data nodes may be selected at once
* @param $value boolean value Y/N
*/
public
function
setmultiple
(
$value
)
{
if
(
trim
(
strtoupper
(
$value
))
==
"Y"
)
{
$this
->
internalMultiSelect
=
true
;
}
else
{
$this
->
internalMultiSelect
=
false
;
}
}
/**
* get valid options, descriptions and selected value
* @return array
...
...
@@ -121,8 +140,9 @@ class ModelRelationField extends BaseField
$result
[
""
]
=
array
(
"value"
=>
"none"
,
"selected"
=>
0
);
}
$datanodes
=
explode
(
','
,
$this
->
internalValue
);
foreach
(
self
::
$internalOptionList
[
$this
->
internalCacheKey
]
as
$optKey
=>
$optValue
)
{
if
(
$optKey
==
$this
->
internalValue
&&
$this
->
internalValue
!=
null
)
{
if
(
in_array
(
$optKey
,
$datanodes
)
)
{
$selected
=
1
;
}
else
{
$selected
=
0
;
...
...
@@ -142,14 +162,9 @@ class ModelRelationField extends BaseField
{
$validators
=
parent
::
getValidators
();
if
(
$this
->
internalValue
!=
null
)
{
if
(
array_key_exists
(
$this
->
internalCacheKey
,
self
::
$internalOptionList
)
&&
count
(
self
::
$internalOptionList
[
$this
->
internalCacheKey
])
>
0
)
{
$validators
[]
=
new
InclusionIn
(
array
(
'message'
=>
$this
->
internalValidationMessage
,
'domain'
=>
array_keys
(
self
::
$internalOptionList
[
$this
->
internalCacheKey
])));
}
else
{
$validators
[]
=
new
InclusionIn
(
array
(
'message'
=>
$this
->
internalValidationMessage
,
'domain'
=>
array
()));
}
// field may contain more than one entries
$validators
[]
=
new
CsvListValidator
(
array
(
'message'
=>
$this
->
internalValidationMessage
,
'domain'
=>
array_keys
(
self
::
$internalOptionList
[
$this
->
internalCacheKey
])));
}
return
$validators
;
}
...
...
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