Commit dba7c02a by Qiang Xue

Fixes #1610: `Html::activeCheckboxList()` and `Html::activeRadioList()` will…

Fixes #1610: `Html::activeCheckboxList()` and `Html::activeRadioList()` will submit an empty string if no checkbox/radio is selected
parent 010e17d9
...@@ -32,7 +32,8 @@ Yii Framework 2 Change Log ...@@ -32,7 +32,8 @@ Yii Framework 2 Change Log
- Enh: Added `favicon.ico` and `robots.txt` to defauly application templates (samdark) - Enh: Added `favicon.ico` and `robots.txt` to defauly application templates (samdark)
- Enh: Added `Widget::autoIdPrefix` to support prefixing automatically generated widget IDs (qiangxue) - Enh: Added `Widget::autoIdPrefix` to support prefixing automatically generated widget IDs (qiangxue)
- Enh: Support for file aliases in console command 'message' (omnilight) - Enh: Support for file aliases in console command 'message' (omnilight)
- Enh: Sort and Paginiation can now create absolute URLs (cebe) - Enh: Sort and Pagination can now create absolute URLs (cebe)
- Chg #1610: `Html::activeCheckboxList()` and `Html::activeRadioList()` will submit an empty string if no checkbox/radio is selected (qiangxue)
- Chg: Renamed `yii\jui\Widget::clientEventsMap` to `clientEventMap` (qiangxue) - Chg: Renamed `yii\jui\Widget::clientEventsMap` to `clientEventMap` (qiangxue)
- Chg: Renamed `ActiveRecord::getPopulatedRelations()` to `getRelatedRecords()` (qiangxue) - Chg: Renamed `ActiveRecord::getPopulatedRelations()` to `getRelatedRecords()` (qiangxue)
- Chg: Renamed `attributeName` and `className` to `targetAttribute` and `targetClass` for `UniqueValidator` and `ExistValidator` (qiangxue) - Chg: Renamed `attributeName` and `className` to `targetAttribute` and `targetClass` for `UniqueValidator` and `ExistValidator` (qiangxue)
......
...@@ -1281,7 +1281,8 @@ class BaseHtml ...@@ -1281,7 +1281,8 @@ class BaseHtml
* @param array $options options (name => config) for the checkbox list. The following options are specially handled: * @param array $options options (name => config) for the checkbox list. The following options are specially handled:
* *
* - unselect: string, the value that should be submitted when none of the checkboxes is selected. * - unselect: string, the value that should be submitted when none of the checkboxes is selected.
* By setting this option, a hidden input will be generated. * You may set this option to be null to prevent default value submission.
* If this option is not set, an empty string will be submitted.
* - separator: string, the HTML code that separates items. * - separator: string, the HTML code that separates items.
* - item: callable, a callback that can be used to customize the generation of the HTML code * - item: callable, a callback that can be used to customize the generation of the HTML code
* corresponding to a single item in $items. The signature of this callback must be: * corresponding to a single item in $items. The signature of this callback must be:
...@@ -1300,7 +1301,7 @@ class BaseHtml ...@@ -1300,7 +1301,7 @@ class BaseHtml
$name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute); $name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute);
$selection = static::getAttributeValue($model, $attribute); $selection = static::getAttributeValue($model, $attribute);
if (!array_key_exists('unselect', $options)) { if (!array_key_exists('unselect', $options)) {
$options['unselect'] = '0'; $options['unselect'] = '';
} }
if (!array_key_exists('id', $options)) { if (!array_key_exists('id', $options)) {
$options['id'] = static::getInputId($model, $attribute); $options['id'] = static::getInputId($model, $attribute);
...@@ -1321,7 +1322,8 @@ class BaseHtml ...@@ -1321,7 +1322,8 @@ class BaseHtml
* @param array $options options (name => config) for the radio button list. The following options are specially handled: * @param array $options options (name => config) for the radio button list. The following options are specially handled:
* *
* - unselect: string, the value that should be submitted when none of the radio buttons is selected. * - unselect: string, the value that should be submitted when none of the radio buttons is selected.
* By setting this option, a hidden input will be generated. * You may set this option to be null to prevent default value submission.
* If this option is not set, an empty string will be submitted.
* - separator: string, the HTML code that separates items. * - separator: string, the HTML code that separates items.
* - item: callable, a callback that can be used to customize the generation of the HTML code * - item: callable, a callback that can be used to customize the generation of the HTML code
* corresponding to a single item in $items. The signature of this callback must be: * corresponding to a single item in $items. The signature of this callback must be:
...@@ -1340,7 +1342,7 @@ class BaseHtml ...@@ -1340,7 +1342,7 @@ class BaseHtml
$name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute); $name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute);
$selection = static::getAttributeValue($model, $attribute); $selection = static::getAttributeValue($model, $attribute);
if (!array_key_exists('unselect', $options)) { if (!array_key_exists('unselect', $options)) {
$options['unselect'] = '0'; $options['unselect'] = '';
} }
if (!array_key_exists('id', $options)) { if (!array_key_exists('id', $options)) {
$options['id'] = static::getInputId($model, $attribute); $options['id'] = static::getInputId($model, $attribute);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment