Merge branch '2.6' into 2.7

This commit is contained in:
mark_story 2015-04-29 19:54:53 -04:00
commit 345d8d8390
2 changed files with 57 additions and 0 deletions

View file

@ -7430,6 +7430,53 @@ class FormHelperTest extends CakeTestCase {
$this->assertNotContains('value="' . date('d') . '" selected="selected"', $result);
}
/**
* testInputDate method
*
* Test various inputs with type date and different option attributes.
*
* @return void
*/
public function testInputDateOptions() {
$this->Form->create('User');
$result = $this->Form->input('date',
array(
'label' => false,
'type' => 'day',
'class' => 'form-control'
)
);
$this->assertContains('class="form-control"', $result);
$result = $this->Form->input('date',
array(
'label' => false,
'type' => 'month',
'class' => 'form-control'
)
);
$this->assertContains('class="form-control"', $result);
$result = $this->Form->input('date',
array(
'label' => false,
'type' => 'year',
'class' => 'form-control'
)
);
$this->assertContains('class="form-control"', $result);
$result = $this->Form->input('date',
array(
'label' => false,
'type' => 'hour',
'class' => 'form-control'
)
);
$this->assertContains('class="form-control"', $result);
}
/**
* testInputDateMaxYear method
*

View file

@ -2213,6 +2213,11 @@ class FormHelper extends AppHelper {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::year
*/
public function year($fieldName, $minYear = null, $maxYear = null, $attributes = array()) {
if (is_array($minYear)) {
$attributes = $minYear;
$minYear = null;
}
$attributes += array('empty' => true, 'value' => null);
if ((empty($attributes['value']) || $attributes['value'] === true) && $value = $this->value($fieldName)) {
if (is_array($value)) {
@ -2310,6 +2315,11 @@ class FormHelper extends AppHelper {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::hour
*/
public function hour($fieldName, $format24Hours = false, $attributes = array()) {
if (is_array($format24Hours)) {
$attributes = $format24Hours;
$format24Hours = false;
}
$attributes += array('empty' => true, 'value' => null);
$attributes = $this->_dateTimeSelected('hour', $fieldName, $attributes);