Skip to content
This repository
Browse code

Fleshing out Number::addFormat

  • Loading branch information...
commit b83b8f8628acc02ba0f19dd4629e57eaf7b59e16 1 parent d8cf371
Kyle Robinson Young authored February 10, 2012

Showing 1 changed file with 35 additions and 10 deletions. Show diff stats Hide diff stats

  1. 45  en/core-libraries/helpers/number.rst
45  en/core-libraries/helpers/number.rst
Source Rendered
@@ -74,22 +74,47 @@ automatically echo the output into the view.
74 74
     :param string $formatName: The format name to be used in the future
75 75
     :param array $options: The array of options for this format.
76 76
 
77  
-    Add a currency format to the Number helper.  Makes reusing
  77
+        - `before` Currency symbol before number. False for none.
  78
+        - `after` Currency symbol after number. False for none.
  79
+        - `zero` The text to use for zero values, can be a string or a number.
  80
+          ie. 0, 'Free!'
  81
+        - `places` Number of decimal places to use. ie. 2.
  82
+        - `thousands` Thousands separator ie. ','.
  83
+        - `decimals` Decimal separator symbol ie. '.'.
  84
+        - `negative` Symbol for negative numbers. If equal to '()', the number
  85
+          will be wrapped with ( and ).
  86
+        - `escape` Should the output be htmlentity escaped? Defaults to true.
  87
+        - `wholeSymbol` String to use for whole numbers ie. ' dollars'.
  88
+        - `wholePosition` Either 'before' or 'after' to place the whole symbol.
  89
+        - `fractionSymbol` String to use for fraction numbers ie. ' cents'.
  90
+        - `fractionPosition` Either 'before' or 'after' to place the fraction
  91
+          symbol.
  92
+
  93
+    Add a currency format to the Number helper. Makes reusing
78 94
     currency formats easier.::
79  
-    
  95
+
80 96
         <?php
81 97
         $this->Number->addFormat('BRR', array('before' => 'R$ '));
82  
-    
83  
-    You can now use `BRR` as a shortform when formatting currency amounts.::
84  
-    
  98
+
  99
+    You can now use `BRR` as a shortform when formatting currency amounts::
  100
+
85 101
         <?php
86 102
         echo $this->Number->currency($value, 'BRR');
87  
-    
88  
-    Added formats are merged with the following defaults.::
89  
-    
  103
+
  104
+    Added formats are merged with the following defaults::
  105
+
  106
+       <?php
90 107
        array(
91  
-           'before' => '$', 'after' => 'c', 'zero' => 0, 'places' => 2, 'thousands' => ',',
92  
-           'decimals' => '.', 'negative' => '()', 'escape' => true
  108
+           'wholeSymbol'      => '',
  109
+           'wholePosition'    => 'before',
  110
+           'fractionSymbol'   => '',
  111
+           'fractionPosition' => 'after',
  112
+           'zero'             => 0,
  113
+           'places'           => 2,
  114
+           'thousands'        => ',',
  115
+           'decimals'         => '.',
  116
+           'negative'         => '()',
  117
+           'escape'           => true
93 118
        )
94 119
 
95 120
 .. php:method:: precision(mixed $number, int $precision = 3)

0 notes on commit b83b8f8

Please sign in to comment.
Something went wrong with that request. Please try again.