Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fleshing out Number::addFormat

  • Loading branch information...
commit b83b8f8628acc02ba0f19dd4629e57eaf7b59e16 1 parent d8cf371
Kyle Robinson Young shama authored
Showing with 35 additions and 10 deletions.
  1. +35 −10 en/core-libraries/helpers/number.rst
45 en/core-libraries/helpers/number.rst
View
@@ -74,22 +74,47 @@ automatically echo the output into the view.
:param string $formatName: The format name to be used in the future
:param array $options: The array of options for this format.
- Add a currency format to the Number helper. Makes reusing
+ - `before` Currency symbol before number. False for none.
+ - `after` Currency symbol after number. False for none.
+ - `zero` The text to use for zero values, can be a string or a number.
+ ie. 0, 'Free!'
+ - `places` Number of decimal places to use. ie. 2.
+ - `thousands` Thousands separator ie. ','.
+ - `decimals` Decimal separator symbol ie. '.'.
+ - `negative` Symbol for negative numbers. If equal to '()', the number
+ will be wrapped with ( and ).
+ - `escape` Should the output be htmlentity escaped? Defaults to true.
+ - `wholeSymbol` String to use for whole numbers ie. ' dollars'.
+ - `wholePosition` Either 'before' or 'after' to place the whole symbol.
+ - `fractionSymbol` String to use for fraction numbers ie. ' cents'.
+ - `fractionPosition` Either 'before' or 'after' to place the fraction
+ symbol.
+
+ Add a currency format to the Number helper. Makes reusing
currency formats easier.::
-
+
<?php
$this->Number->addFormat('BRR', array('before' => 'R$ '));
-
- You can now use `BRR` as a shortform when formatting currency amounts.::
-
+
+ You can now use `BRR` as a shortform when formatting currency amounts::
+
<?php
echo $this->Number->currency($value, 'BRR');
-
- Added formats are merged with the following defaults.::
-
+
+ Added formats are merged with the following defaults::
+
+ <?php
array(
- 'before' => '$', 'after' => 'c', 'zero' => 0, 'places' => 2, 'thousands' => ',',
- 'decimals' => '.', 'negative' => '()', 'escape' => true
+ 'wholeSymbol' => '',
+ 'wholePosition' => 'before',
+ 'fractionSymbol' => '',
+ 'fractionPosition' => 'after',
+ 'zero' => 0,
+ 'places' => 2,
+ 'thousands' => ',',
+ 'decimals' => '.',
+ 'negative' => '()',
+ 'escape' => true
)
.. php:method:: precision(mixed $number, int $precision = 3)
Please sign in to comment.
Something went wrong with that request. Please try again.