mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge branch '1.2' of code.cakephp.org:cakephp into 1.2
This commit is contained in:
commit
daafac8a64
2 changed files with 18 additions and 1 deletions
|
@ -1721,7 +1721,7 @@ class FormHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($name !== null) {
|
if ($name !== null) {
|
||||||
if ((!$selectedIsEmpty && $selected == $name) || ($selectedIsArray && in_array($name, $selected))) {
|
if ((!$selectedIsEmpty && (string)$selected == (string)$name) || ($selectedIsArray && in_array($name, $selected))) {
|
||||||
if ($attributes['style'] === 'checkbox') {
|
if ($attributes['style'] === 'checkbox') {
|
||||||
$htmlOptions['checked'] = true;
|
$htmlOptions['checked'] = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2687,6 +2687,23 @@ class FormHelperTest extends CakeTestCase {
|
||||||
'/select'
|
'/select'
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
$this->Form->data = array('Model' => array('contact_id' => 228));
|
||||||
|
$result = $this->Form->select(
|
||||||
|
'Model.contact_id',
|
||||||
|
array('228' => '228 value', '228-1' => '228-1 value', '228-2' => '228-2 value'),
|
||||||
|
null, array('escape' => false), 'pick something'
|
||||||
|
);
|
||||||
|
|
||||||
|
$expected = array(
|
||||||
|
'select' => array('name' => 'data[Model][contact_id]', 'id' => 'ModelContactId'),
|
||||||
|
array('option' => array('value' => '')), 'pick something', '/option',
|
||||||
|
array('option' => array('value' => '228', 'selected' => 'selected')), '228 value', '/option',
|
||||||
|
array('option' => array('value' => '228-1')), '228-1 value', '/option',
|
||||||
|
array('option' => array('value' => '228-2')), '228-2 value', '/option',
|
||||||
|
'/select'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Tests that FormHelper::select() allows null to be passed in the $attributes parameter
|
* Tests that FormHelper::select() allows null to be passed in the $attributes parameter
|
||||||
|
|
Loading…
Reference in a new issue