Form Demo

When working with decimals coming from DB and displaying it both in views and forms, we want to check how nice the value objects work here for us.

For this to work directly with the object for all our decimal columns we mapped them to the Type class:

\Cake\Database\TypeFactory::map(
    'decimal',
    'CakeDecimal\Database\Type\DecimalObjectType',
);

We then pull a record from DB. If we echo the `balance` field:

PhpCollective\DecimalObject\Decimal Object
(
    [value] => 0.00
    [scale] => 2
)

The `extra` field is first empty (null):

Now, lets add something to it via edit form

Set balance and extra amount

`balance` is a required not null field, `extra` is nullable.


Send your feedback or bugreport!