mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 13:02:24 +08:00
Fixes #11960: Fixed checked option ignore in yii\helpers\BaseHtml::checkbox()
This commit is contained in:
committed by
Alexander Makarov
parent
0ad5afd387
commit
af3b8b2f23
@ -4,6 +4,7 @@ Yii Framework 2 Change Log
|
||||
2.0.16 under development
|
||||
------------------------
|
||||
|
||||
- Bug #11960: Fixed `checked` option ignore in `yii\helpers\BaseHtml::checkbox()` (misantron)
|
||||
- Bug #14759: Fixed `yii\web\JsonResponseFormatter` output for `null` data (misantron)
|
||||
- Bug #16490: Fix schema on rbac init (marcelodeandrade)
|
||||
- Bug #16748: Fixed params when normalize data (marcelodeandrade)
|
||||
|
||||
@ -751,7 +751,10 @@ class BaseHtml
|
||||
*/
|
||||
protected static function booleanInput($type, $name, $checked = false, $options = [])
|
||||
{
|
||||
$options['checked'] = (bool) $checked;
|
||||
// 'checked' option has priority over $checked argument
|
||||
if (!isset($options['checked'])) {
|
||||
$options['checked'] = (bool) $checked;
|
||||
}
|
||||
$value = array_key_exists('value', $options) ? $options['value'] : '1';
|
||||
if (isset($options['uncheck'])) {
|
||||
// add a hidden field so that if the checkbox is not selected, it still submits a value
|
||||
|
||||
@ -477,6 +477,13 @@ class HtmlTest extends TestCase
|
||||
'value' => 2,
|
||||
'form' => 'test-form',
|
||||
]));
|
||||
$this->assertEquals('<input type="hidden" name="test" value="0"><label><input type="checkbox" class="a" name="test" value="2" checked> ccc</label>', Html::checkbox('test', false, [
|
||||
'class' => 'a',
|
||||
'uncheck' => '0',
|
||||
'label' => 'ccc',
|
||||
'value' => 2,
|
||||
'checked' => true,
|
||||
]));
|
||||
}
|
||||
|
||||
public function testDropDownList()
|
||||
|
||||
Reference in New Issue
Block a user