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
088ca266
Commit
088ca266
authored
Mar 29, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(mvc, fieldtype) wrong event for setting initial data in UniqueIdField
parent
e5cbe0cf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
11 deletions
+8
-11
UniqueIdField.php
...mvc/app/models/OPNsense/Base/FieldTypes/UniqueIdField.php
+8
-11
No files found.
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/UniqueIdField.php
View file @
088ca266
...
...
@@ -51,23 +51,20 @@ class UniqueIdField extends BaseField
*/
private
$initialValue
=
null
;
/**
* generate unique id (if none available) and store previous value for comparison before save
*/
public
function
eventPostLoading
()
{
if
(
empty
(
$this
->
internalValue
))
{
$this
->
internalValue
=
uniqid
(
''
,
true
);
}
$this
->
initialValue
=
$this
->
internalValue
;
}
/**
* retrieve field validators for this field type
* @return array
*/
public
function
getValidators
()
{
if
(
empty
(
$this
->
internalValue
)
&&
empty
(
$this
->
initialValue
))
{
// trigger initial value on change, before returning validators
// (new nodes will always be marked as "changed", see isFieldChanged())
// Maybe we should add an extra event handler if this kind of scenarios happen more often, similar to
// actionPostLoadingEvent. (which is not triggered on setting data for a complete new structure node)
$this
->
internalValue
=
uniqid
(
''
,
true
);
$this
->
initialValue
=
$this
->
internalValue
;
}
$validators
=
parent
::
getValidators
();
// unique id may not change..
$validators
[]
=
new
InclusionIn
(
array
(
'message'
=>
$this
->
internalValidationMessage
,
...
...
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