Fixes #11960: Fixed checked option ignore in yii\helpers\BaseHtml::checkbox()

This commit is contained in:
Alexandr Ivanov
2018-10-07 16:29:08 +03:00
committed by Alexander Makarov
parent 0ad5afd387
commit af3b8b2f23
3 changed files with 12 additions and 1 deletions

View File

@ -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)

View File

@ -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