mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
month function + tests
This commit is contained in:
parent
529791842c
commit
6620b3b8fc
2 changed files with 7 additions and 7 deletions
|
@ -1581,14 +1581,13 @@ class FormHelper extends AppHelper {
|
|||
* that string is displayed as the empty element.
|
||||
*
|
||||
* @param string $fieldName Prefix name for the SELECT element
|
||||
* @param string $selected Option which is selected.
|
||||
* @param array $attributes Attributes for the select element
|
||||
* @return string A generated month select dropdown.
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1417/month
|
||||
*/
|
||||
public function month($fieldName, $selected = null, $attributes = array()) {
|
||||
$attributes += array('empty' => true, 'value' => $selected);
|
||||
public function month($fieldName, $attributes = array()) {
|
||||
$attributes += array('empty' => true, 'value' => null);
|
||||
$attributes = $this->__dateTimeSelected('month', $fieldName, $attributes);
|
||||
|
||||
if (strlen($attributes['value']) > 2) {
|
||||
|
@ -1885,8 +1884,9 @@ class FormHelper extends AppHelper {
|
|||
);
|
||||
break;
|
||||
case 'M':
|
||||
$selectMonthAttr['value'] = $month;
|
||||
$selectMonthAttr['monthNames'] = $monthNames;
|
||||
$selects[] = $this->month($fieldName, $month, $selectMonthAttr);
|
||||
$selects[] = $this->month($fieldName, $selectMonthAttr);
|
||||
break;
|
||||
case 'D':
|
||||
$selectDayAttr['value'] = $day;
|
||||
|
|
|
@ -4500,7 +4500,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->month('Model.field', null, array('empty' => true));
|
||||
$result = $this->Form->month('Model.field', array('empty' => true));
|
||||
$expected = array(
|
||||
array('select' => array('name' => 'data[Model][field][month]', 'id' => 'ModelFieldMonth')),
|
||||
array('option' => array('value' => '')),
|
||||
|
@ -4515,7 +4515,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->month('Model.field', null, array('monthNames' => false));
|
||||
$result = $this->Form->month('Model.field', array('monthNames' => false));
|
||||
$expected = array(
|
||||
array('select' => array('name' => 'data[Model][field][month]', 'id' => 'ModelFieldMonth')),
|
||||
array('option' => array('value' => '')),
|
||||
|
@ -4533,7 +4533,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
$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));
|
||||
$result = $this->Form->month('Model.field', array('monthNames' => $monthNames));
|
||||
$expected = array(
|
||||
array('select' => array('name' => 'data[Model][field][month]', 'id' => 'ModelFieldMonth')),
|
||||
array('option' => array('value' => '')),
|
||||
|
|
Loading…
Reference in a new issue