mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Making optiongroup elements follow the escape parameter.
Tests added. Fixes #1191
This commit is contained in:
parent
3f2109f3c3
commit
6529e0e2b4
2 changed files with 42 additions and 0 deletions
|
@ -2002,6 +2002,7 @@ class FormHelper extends AppHelper {
|
||||||
));
|
));
|
||||||
|
|
||||||
if (!empty($name)) {
|
if (!empty($name)) {
|
||||||
|
$name = $attributes['escape'] ? h($name) : $name;
|
||||||
if ($attributes['style'] === 'checkbox') {
|
if ($attributes['style'] === 'checkbox') {
|
||||||
$select[] = sprintf($this->Html->tags['fieldsetstart'], $name);
|
$select[] = sprintf($this->Html->tags['fieldsetstart'], $name);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3115,6 +3115,47 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test that select() with optiongroups listens to the escape param.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testSelectOptionGroupEscaping() {
|
||||||
|
$options = array(
|
||||||
|
'>< Key' => array(
|
||||||
|
1 => 'One',
|
||||||
|
2 => 'Two'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$result = $this->Form->select('Model.field', $options, null, array('empty' => false));
|
||||||
|
$expected = array(
|
||||||
|
'select' => array('name' => 'data[Model][field]', 'id' => 'ModelField'),
|
||||||
|
'optgroup' => array('label' => '>< Key'),
|
||||||
|
array('option' => array('value' => '1')), 'One', '/option',
|
||||||
|
array('option' => array('value' => '2')), 'Two', '/option',
|
||||||
|
'/optgroup',
|
||||||
|
'/select'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
$options = array(
|
||||||
|
'>< Key' => array(
|
||||||
|
1 => 'One',
|
||||||
|
2 => 'Two'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$result = $this->Form->select('Model.field', $options, null, array('empty' => false, 'escape' => false));
|
||||||
|
$expected = array(
|
||||||
|
'select' => array('name' => 'data[Model][field]', 'id' => 'ModelField'),
|
||||||
|
'optgroup' => array('label' => '>< Key'),
|
||||||
|
array('option' => array('value' => '1')), 'One', '/option',
|
||||||
|
array('option' => array('value' => '2')), 'Two', '/option',
|
||||||
|
'/optgroup',
|
||||||
|
'/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…
Add table
Reference in a new issue