mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 05:48:11 +08:00
Fixes #7946 Fixed a bug when the form attribute was not propagated to the hidden input of the checkbox
This commit is contained in:
committed by
Alexander Makarov
parent
953a0bba2b
commit
f47b6c7683
@ -4,6 +4,7 @@ Yii Framework 2 Change Log
|
||||
2.0.12 under development
|
||||
--------------------------
|
||||
|
||||
- Bug #7946 Fixed a bug when the `form` attribute was not propagated to the hidden input of the checkbox (Kolyunya)
|
||||
- Bug #13087: Fixed getting active validators for safe attribute (developeruz)
|
||||
- Bug #13571: Fix `yii\db\mssql\QueryBuilder::checkIntegrity` for all tables (boboldehampsink)
|
||||
- Bug #11230: Include `defaultRoles` in `yii\rbac\DbManager->getRolesByUser()` results (developeruz)
|
||||
|
||||
@ -60,6 +60,7 @@ class BaseHtml
|
||||
'href',
|
||||
'src',
|
||||
'srcset',
|
||||
'form',
|
||||
'action',
|
||||
'method',
|
||||
|
||||
@ -742,7 +743,11 @@ class BaseHtml
|
||||
$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
|
||||
$hidden = static::hiddenInput($name, $options['uncheck']);
|
||||
$hiddenOptions = [];
|
||||
if (isset($options['form'])) {
|
||||
$hiddenOptions['form'] = $options['form'];
|
||||
}
|
||||
$hidden = static::hiddenInput($name, $options['uncheck'], $hiddenOptions);
|
||||
unset($options['uncheck']);
|
||||
} else {
|
||||
$hidden = '';
|
||||
|
||||
@ -378,6 +378,13 @@ class HtmlTest extends TestCase
|
||||
'label' => 'ccc',
|
||||
'value' => 2,
|
||||
]));
|
||||
$this->assertEquals('<input type="hidden" name="test" value="0" form="test-form"><label><input type="checkbox" class="a" name="test" value="2" form="test-form" checked> ccc</label>', Html::checkbox('test', true, [
|
||||
'class' => 'a',
|
||||
'uncheck' => '0',
|
||||
'label' => 'ccc',
|
||||
'value' => 2,
|
||||
'form' => 'test-form',
|
||||
]));
|
||||
}
|
||||
|
||||
public function testDropDownList()
|
||||
|
||||
Reference in New Issue
Block a user