mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
fix issue with FormHelper and undefined variable and extract
This commit is contained in:
parent
290c343a74
commit
ee5e8c95dd
2 changed files with 17 additions and 6 deletions
|
@ -6631,12 +6631,21 @@ class FormHelperTest extends CakeTestCase {
|
|||
/**
|
||||
* 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 @@ class FormHelperTest extends CakeTestCase {
|
|||
)
|
||||
);
|
||||
$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 @@ class FormHelperTest extends CakeTestCase {
|
|||
'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 @@ class FormHelperTest extends CakeTestCase {
|
|||
'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 @@ class FormHelperTest extends CakeTestCase {
|
|||
'empty' => false,
|
||||
)
|
||||
);
|
||||
$this->assertContains('value="' . date('d') . '" selected="selected"', $result);
|
||||
$this->assertNotContains('value="' . date('d') . '" selected="selected"', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2114,6 +2114,7 @@ class FormHelper extends AppHelper {
|
|||
$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 @@ class FormHelper extends AppHelper {
|
|||
$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 {
|
||||
|
|
Loading…
Reference in a new issue