Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix issue with FormHelper and undefined variable and extract

  • Loading branch information...
commit ee5e8c95dd7306665f6a69316618f3a1848ee088 1 parent 290c343
@dereuromark dereuromark authored
View
21 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -6631,12 +6631,21 @@ public function testYearAutoExpandRange() {
/**
* testInputDate method
*
- * Test various inputs with type date and different dateFormat values
+ * Test various inputs with type date and different dateFormat values.
+ * Failing to provide a dateFormat key should not error.
+ * It should simply not pre-select any value then.
*
* @return void
*/
public function testInputDate() {
- $this->Form->request->data = array();
+ $this->Form->request->data = array(
+ 'User' => array(
+ 'month_year' => array('month' => date('m')),
+ 'just_year' => array('month' => date('m')),
+ 'just_month' => array('year' => date('Y')),
+ 'just_day' => array('month' => date('m')),
+ )
+ );
$this->Form->create('User');
$result = $this->Form->input('month_year',
array(
@@ -6649,7 +6658,7 @@ public function testInputDate() {
)
);
$this->assertContains('value="' . date('m') . '" selected="selected"', $result);
- $this->assertContains('value="2008" selected="selected"', $result);
+ $this->assertNotContains('value="2008" selected="selected"', $result);
$result = $this->Form->input('just_year',
array(
@@ -6660,7 +6669,7 @@ public function testInputDate() {
'maxYear' => date('Y', strtotime('+20 years'))
)
);
- $this->assertContains('value="' . date('Y') . '" selected="selected"', $result);
+ $this->assertNotContains('value="' . date('Y') . '" selected="selected"', $result);
$result = $this->Form->input('just_month',
array(
@@ -6670,7 +6679,7 @@ public function testInputDate() {
'empty' => false,
)
);
- $this->assertContains('value="' . date('m') . '" selected="selected"', $result);
+ $this->assertNotContains('value="' . date('m') . '" selected="selected"', $result);
$result = $this->Form->input('just_day',
array(
@@ -6680,7 +6689,7 @@ public function testInputDate() {
'empty' => false,
)
);
- $this->assertContains('value="' . date('d') . '" selected="selected"', $result);
+ $this->assertNotContains('value="' . date('d') . '" selected="selected"', $result);
}
/**
View
2  lib/Cake/View/Helper/FormHelper.php
@@ -2114,6 +2114,7 @@ public function year($fieldName, $minYear = null, $maxYear = null, $attributes =
$attributes += array('empty' => true, 'value' => null);
if ((empty($attributes['value']) || $attributes['value'] === true) && $value = $this->value($fieldName)) {
if (is_array($value)) {
+ $year = null;
extract($value);
$attributes['value'] = $year;
} else {
@@ -2305,6 +2306,7 @@ public function meridian($fieldName, $attributes = array()) {
$attributes += array('empty' => true, 'value' => null);
if ((empty($attributes['value']) || $attributes['value'] === true) && $value = $this->value($fieldName)) {
if (is_array($value)) {
+ $meridian = null;
extract($value);
$attributes['value'] = $meridian;
} else {
Please sign in to comment.
Something went wrong with that request. Please try again.