Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
bd5e0494
Commit
bd5e0494
authored
11 years ago
by
Alex Pott
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2086305
by larowlan: Add a FloatItem data type.
parent
4b72c960
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/lib/Drupal/Core/Entity/Plugin/DataType/FloatItem.php
+48
-0
48 additions, 0 deletions
core/lib/Drupal/Core/Entity/Plugin/DataType/FloatItem.php
core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php
+2
-2
2 additions, 2 deletions
...ystem/lib/Drupal/system/Tests/TypedData/TypedDataTest.php
with
50 additions
and
2 deletions
core/lib/Drupal/Core/Entity/Plugin/DataType/FloatItem.php
0 → 100644
+
48
−
0
View file @
bd5e0494
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Plugin\DataType\FloatItem.
*/
namespace
Drupal\Core\Entity\Plugin\DataType
;
use
Drupal\Core\TypedData\Annotation\DataType
;
use
Drupal\Core\Annotation\Translation
;
use
Drupal\Core\Entity\Field\FieldItemBase
;
/**
* Defines the 'float_field' entity field item.
*
* @DataType(
* id = "float_field",
* label = @Translation("Float field item"),
* description = @Translation("An entity field containing an float value."),
* list_class = "\Drupal\Core\Entity\Field\Field"
* )
*/
class
FloatItem
extends
FieldItemBase
{
/**
* Definitions of the contained properties.
*
* @see IntegerItem::getPropertyDefinitions()
*
* @var array
*/
static
$propertyDefinitions
;
/**
* Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyDefinitions().
*/
public
function
getPropertyDefinitions
()
{
if
(
!
isset
(
static
::
$propertyDefinitions
))
{
static
::
$propertyDefinitions
[
'value'
]
=
array
(
'type'
=>
'float'
,
'label'
=>
t
(
'Float value'
),
);
}
return
static
::
$propertyDefinitions
;
}
}
This diff is collapsed.
Click to expand it.
core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php
+
2
−
2
View file @
bd5e0494
...
...
@@ -569,12 +569,12 @@ public function testTypedDataValidation() {
// Test the Null constraint with typed data containers.
$definition
=
array
(
'type'
=>
'
integer
_field'
,
'type'
=>
'
float
_field'
,
'constraints'
=>
array
(
'Null'
=>
array
(),
),
);
$field_item
=
$this
->
typedData
->
create
(
$definition
,
array
(
'value'
=>
1
0
));
$field_item
=
$this
->
typedData
->
create
(
$definition
,
array
(
'value'
=>
1
1.5
));
$violations
=
$field_item
->
validate
();
$this
->
assertEqual
(
$violations
->
count
(),
1
);
$field_item
=
$this
->
typedData
->
create
(
$definition
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment