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
539e6767
Commit
539e6767
authored
May 15, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(mvc model) apply defaults on new array items
parent
4f728e38
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
ArrayField.php
...se/mvc/app/models/OPNsense/Base/FieldTypes/ArrayField.php
+5
-2
BaseField.php
...nse/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php
+14
-0
No files found.
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/ArrayField.php
View file @
539e6767
...
...
@@ -103,12 +103,15 @@ class ArrayField extends BaseField
);
foreach
(
$new_record
as
$key
=>
$node
)
{
// initialize field with new internal id and defined default value
$node
->
setInternalReference
(
$container_node
->
__reference
.
"."
.
$key
);
$node
->
applyDefault
();
$container_node
->
addChildNode
(
$key
,
$node
);
// make sure we have a UUID on repeating child items
$container_node
->
setAttributeValue
(
"uuid"
,
$this
->
generateUUID
());
}
// make sure we have a UUID on repeating child items
$container_node
->
setAttributeValue
(
"uuid"
,
$this
->
generateUUID
());
// add node to this object
$this
->
addChildNode
(
null
,
$container_node
);
...
...
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php
View file @
539e6767
...
...
@@ -55,6 +55,11 @@ abstract class BaseField
*/
protected
$internalValue
=
""
;
/**
* @var null|string node default value
*/
protected
$internalDefaultValue
=
""
;
/**
* @var string direct reference to this field in the model object
*/
...
...
@@ -426,6 +431,15 @@ abstract class BaseField
public
function
setDefault
(
$value
)
{
$this
->
internalValue
=
$value
;
$this
->
internalDefaultValue
=
$value
;
}
/**
* (re)Apply default value
*/
public
function
applyDefault
()
{
$this
->
internalValue
=
$this
->
internalDefaultValue
;
}
/**
...
...
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