Skip to content

Commit

Permalink
Merge branch '1.3-misc' of dev@code.cakephp.org:cakephp into 1.3-misc
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Nov 3, 2009
2 parents fc9cecc + 5ebdc88 commit 055b5c6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cake/console/libs/tasks/extract.php
Expand Up @@ -49,7 +49,7 @@ class ExtractTask extends Shell {
* Merge all domains string into the default.pot file
*
* @var boolean
* @access public
* @access private
*/
var $__merge = false;

Expand Down
12 changes: 8 additions & 4 deletions cake/libs/view/helpers/form.php
Expand Up @@ -653,7 +653,7 @@ function input($fieldName, $options = array()) {
$this->_inputDefaults,
$options
);

$modelKey = $this->model();
$fieldKey = $this->field();
if (!isset($this->fieldset[$modelKey])) {
Expand Down Expand Up @@ -1422,7 +1422,8 @@ function year($fieldName, $minYear = null, $maxYear = null, $selected = null, $a
*
* Attributes:
*
* - `monthNames` is set and false 2 digit numbers will be used instead of text.
* - `monthNames` - If false, 2 digit numbers will be used instead of text.
* If a array, the given array will be used.
* - `empty` - If true, the empty select option is shown. If a string,
* that string is displayed as the empty element.
*
Expand Down Expand Up @@ -1591,7 +1592,8 @@ function meridian($fieldName, $selected = null, $attributes = array()) {
*
* Attributes:
*
* - `monthNames` If set and false numbers will be used for month select instead of text.
* - `monthNames` If false, 2 digit numbers will be used instead of text.
* If a array, the given array will be used.
* - `minYear` The lowest year to use in the year select
* - `maxYear` The maximum year to use in the year select
* - `interval` The interval for the minutes select. Defaults to 1
Expand Down Expand Up @@ -1916,7 +1918,7 @@ function __generateOptions($name, $options = array()) {
}
break;
case 'month':
if ($options['monthNames']) {
if ($options['monthNames'] === true) {
$data['01'] = __('January', true);
$data['02'] = __('February', true);
$data['03'] = __('March', true);
Expand All @@ -1929,6 +1931,8 @@ function __generateOptions($name, $options = array()) {
$data['10'] = __('October', true);
$data['11'] = __('November', true);
$data['12'] = __('December', true);
} else if (is_array($options['monthNames'])) {
$data = $options['monthNames'];
} else {
for ($m = 1; $m <= 12; $m++) {
$data[sprintf("%02s", $m)] = strftime("%m", mktime(1, 1, 1, $m, 1, 1999));
Expand Down
33 changes: 33 additions & 0 deletions cake/tests/cases/libs/view/helpers/form.test.php
Expand Up @@ -4023,6 +4023,39 @@ function testMonth() {
'*/select',
);
$this->assertTags($result, $expected);

$result = $this->Form->month('Model.field', null, array('monthNames' => false));
$expected = array(
array('select' => array('name' => 'data[Model][field][month]', 'id' => 'ModelFieldMonth')),
array('option' => array('value' => '')),
'/option',
array('option' => array('value' => '01')),
'01',
'/option',
array('option' => array('value' => '02')),
'02',
'/option',
'*/select',
);
$this->assertTags($result, $expected);

$monthNames = array(
'01' => 'Jan', '02' => 'Feb', '03' => 'Mar', '04' => 'Apr', '05' => 'May', '06' => 'Jun',
'07' => 'Jul', '08' => 'Aug', '09' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec');
$result = $this->Form->month('Model.field', null, array('monthNames' => $monthNames));
$expected = array(
array('select' => array('name' => 'data[Model][field][month]', 'id' => 'ModelFieldMonth')),
array('option' => array('value' => '')),
'/option',
array('option' => array('value' => '01')),
'Jan',
'/option',
array('option' => array('value' => '02')),
'Feb',
'/option',
'*/select',
);
$this->assertTags($result, $expected);
}

/**
Expand Down

0 comments on commit 055b5c6

Please sign in to comment.