octicon-rss(16/)
You've already forked yii2
mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-10 02:13:17 +08:00
Merge branch 'cyphix333-master'
This commit is contained in:
octicon-git-branch(16/)
octicon-tag(16/)
octicon-diff(16/tw-mr-1) 3 changed files with 46 additions and 4 deletions
@@ -45,6 +45,7 @@ Yii Framework 2 Change Log
|
||||
- Enh #12901: Added `getDefaultHelpHeader` method to the `yii\console\controllers\HelpController` class to be able to override default help header in a class heir (diezztsk)
|
||||
- Enh #13035: Use ArrayHelper::getValue() in SluggableBehavior::getValue() (thyseus)
|
||||
- Enh #13020: Added `disabledListItemSubTagOptions` attribute for `yii\widgets\LinkPager` in order to customize the disabled list item sub tag element (nadar)
|
||||
- Enh #12988: Changed `textarea` method within the `yii\helpers\BaseHtml` class to allow users to control whether html entities found within `$value` will be double-encoded or not (cyphix333)
|
||||
- Enh: Added constants for specifying `yii\validators\CompareValidator::$type` (cebe)
|
||||
|
||||
|
||||
|
||||
@@ -660,12 +660,18 @@ class BaseHtml
|
||||
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
|
||||
* If a value is null, the corresponding attribute will not be rendered.
|
||||
* See [[renderTagAttributes()]] for details on how attributes are being rendered.
|
||||
* The following special options are recognized:
|
||||
*
|
||||
* - `doubleEncode`: whether to double encode HTML entities in `$value`. If `false`, HTML entities in `$value` will not
|
||||
* be further encoded. This option is available since version 2.0.11.
|
||||
*
|
||||
* @return string the generated text area tag
|
||||
*/
|
||||
public static function textarea($name, $value = '', $options = [])
|
||||
{
|
||||
$options['name'] = $name;
|
||||
return static::tag('textarea', static::encode($value), $options);
|
||||
$doubleEncode = ArrayHelper::remove($options, 'doubleEncode', true);
|
||||
return static::tag('textarea', static::encode($value, $doubleEncode), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -213,10 +213,45 @@ class HtmlTest extends TestCase
|
||||
$this->assertEquals('<input type="file" class="t" name="test" value="value">', Html::fileInput('test', 'value', ['class' => 't']));
|
||||
}
|
||||
|
||||
public function testTextarea()
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function textareaDataProvider()
|
||||
{
|
||||
$this->assertEquals('<textarea name="test"></textarea>', Html::textarea('test'));
|
||||
$this->assertEquals('<textarea class="t" name="test">value<></textarea>', Html::textarea('test', 'value<>', ['class' => 't']));
|
||||
return [
|
||||
[
|
||||
'<textarea name="test"></textarea>',
|
||||
'test',
|
||||
null,
|
||||
[]
|
||||
],
|
||||
[
|
||||
'<textarea class="t" name="test">value<></textarea>',
|
||||
'test',
|
||||
'value<>',
|
||||
['class' => 't']
|
||||
],
|
||||
[
|
||||
'<textarea name="test">value&lt;&gt;</textarea>',
|
||||
'test',
|
||||
'value<>',
|
||||
[]
|
||||
],
|
||||
[
|
||||
'<textarea name="test">value<></textarea>',
|
||||
'test',
|
||||
'value<>',
|
||||
['doubleEncode' => false]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider textareaDataProvider
|
||||
*/
|
||||
public function testTextarea($expected, $name, $value, $options)
|
||||
{
|
||||
$this->assertEquals($expected, Html::textarea($name, $value, $options));
|
||||
}
|
||||
|
||||
public function testRadio()
|
||||
|
||||
Reference in New Issue
Block a user