@@ -306,7 +306,7 @@ function create($model = null, $options = array()) {
306
306
*
307
307
* {{{
308
308
* array usage:
309
- *
309
+ *
310
310
* array('label' => 'save'); value="save"
311
311
* array('label' => 'save', 'name' => 'Whatever'); value="save" name="Whatever"
312
312
* array('name' => 'Whatever'); value="Submit" name="Whatever"
@@ -389,7 +389,7 @@ function secure($fields = array()) {
389
389
}
390
390
391
391
/**
392
- * Determine which fields of a form should be used for hash.
392
+ * Determine which fields of a form should be used for hash.
393
393
* Populates $this->fields
394
394
*
395
395
* @param mixed $field Reference to field to be secured
@@ -644,7 +644,7 @@ function inputs($fields = null, $blacklist = null) {
644
644
*
645
645
* - `type` - Force the type of widget you want. e.g. `type => 'select'`
646
646
* - `label` - Either a string label, or an array of options for the label. See FormHelper::label()
647
- * - `div` - Either `false` to disable the div, or an array of options for the div.
647
+ * - `div` - Either `false` to disable the div, or an array of options for the div.
648
648
* See HtmlHelper::div() for more options.
649
649
* - `options` - for widgets that take options e.g. radio, select
650
650
* - `error` - control the error message that is produced
@@ -1412,6 +1412,8 @@ function day($fieldName, $selected = null, $attributes = array()) {
1412
1412
*
1413
1413
* - `empty` - If true, the empty select option is shown. If a string,
1414
1414
* that string is displayed as the empty element.
1415
+ * - `orderYear` - Ordering of year values in select options.
1416
+ * Possible values 'asc', 'desc'. Default 'desc'
1415
1417
*
1416
1418
* @param string $fieldName Prefix name for the SELECT element
1417
1419
* @param integer $minYear First year in sequence
@@ -1446,9 +1448,13 @@ function year($fieldName, $minYear = null, $maxYear = null, $selected = null, $a
1446
1448
} elseif ($ selected === false ) {
1447
1449
$ selected = null ;
1448
1450
}
1449
- $ yearOptions = array ('min ' => $ minYear , 'max ' => $ maxYear );
1451
+ $ yearOptions = array ('min ' => $ minYear , 'max ' => $ maxYear , 'order ' => 'desc ' );
1452
+ if (isset ($ attributes ['orderYear ' ])) {
1453
+ $ yearOptions ['order ' ] = $ attributes ['orderYear ' ];
1454
+ unset($ attributes ['orderYear ' ]);
1455
+ }
1450
1456
return $ this ->select (
1451
- $ fieldName . " .year " , $ this ->__generateOptions ('year ' , $ yearOptions ),
1457
+ $ fieldName . ' .year ' , $ this ->__generateOptions ('year ' , $ yearOptions ),
1452
1458
$ selected , $ attributes
1453
1459
);
1454
1460
}
@@ -1862,7 +1868,7 @@ function __selectOptions($elements = array(), $selected = null, $parents = array
1862
1868
1863
1869
if ($ name !== null ) {
1864
1870
if (
1865
- (!$ selectedIsArray && !$ selectedIsEmpty && (string )$ selected == (string )$ name ) ||
1871
+ (!$ selectedIsArray && !$ selectedIsEmpty && (string )$ selected == (string )$ name ) ||
1866
1872
($ selectedIsArray && in_array ($ name , $ selected ))
1867
1873
) {
1868
1874
if ($ attributes ['style ' ] === 'checkbox ' ) {
@@ -2005,7 +2011,9 @@ function __generateOptions($name, $options = array()) {
2005
2011
for ($ i = $ min ; $ i <= $ max ; $ i ++) {
2006
2012
$ data [$ i ] = $ i ;
2007
2013
}
2008
- $ data = array_reverse ($ data , true );
2014
+ if ($ options ['order ' ] != 'asc ' ) {
2015
+ $ data = array_reverse ($ data , true );
2016
+ }
2009
2017
break ;
2010
2018
}
2011
2019
$ this ->__options [$ name ] = $ data ;
0 commit comments