Message-ID: <534266313.3078.1485851885345.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3077_355675408.1485851885345" ------=_Part_3077_355675408.1485851885345 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html The Float FieldType

The Float FieldType

This field type represents a float value.

Name Internal name Expected input
Float ezfloat float

Table of contents:

=20 =20

Description


This FieldType stores numeric values which will be provided as floats.

Input expectations 


The FieldType expects a number as inp= ut. Both decimal and integer numbers are accepted.

Type Example
float

194079.572

int 144

Value object


Properties

The Value class of this field type contains the following properties:

Property Type Description
$value float This property will be used to stor= e the value provided as a float.
Value object content example
=20
use eZ\Publish\Core\FieldType\Float\Type;

// Instantiates a Float Value object
$floatValue =3D new Type\Value();

$float->value =3D 284.773
=20

Constructor

The Float\Value constructor will&nbs= p;initialize a new Value object with the value provided. It expects a numer= ic value with or without decimals.

Constructor example
=20
use eZ\Publish\Core\FieldType\Float\Type;

// Instantiates a Float Value object
$floatValue =3D new Type\Value( 284.773 );
=20

Validation


This FieldType supports FloatValueValidator, defining maximal and minimal float value:

Name Type Default value Description
minFloatValue float false / SINCE 5.4.9 = null
This setting defines the minimum value this Fiel= dType will allow as input.
maxFloatValue float false /= SINCE 5.4.9 null
This setting defines the maximum v= alue this FieldType will allow as input.
Validator configuration example in PHP
=20
use eZ\Publish\Core\FieldType\Float\Type;
 =20
$contentTypeService =3D $repository->getContentTypeService();
$floatFieldCreateStruct =3D $contentTypeService->newFieldDefinitionCreat=
eStruct( "float", "ezfloat" );
=20
// Accept only numbers between 0.1 and 203.99
$floatFieldCreateStruct->validatorConfiguration =3D array(
    "FileSizeValidator" =3D> array(=09
=09=09"minFloatValue" =3D> 0.1,
=09=09"maxFloatValue" =3D> 203.99
    )
);
=20

Settings


This FieldType does not support settings.

 

------=_Part_3077_355675408.1485851885345--