mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Fix #17929: Actions can now have bool typed params bound
This commit is contained in:
@ -4,6 +4,7 @@ Yii Framework 2 Change Log
|
|||||||
2.0.33 under development
|
2.0.33 under development
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
- Enh #17929: Actions can now have bool typed params bound (alex-code)
|
||||||
- Enh #17827: Add `StringValidator::$strict` that can be turned off to allow any scalars (adhayward, samdark)
|
- Enh #17827: Add `StringValidator::$strict` that can be turned off to allow any scalars (adhayward, samdark)
|
||||||
- Bug #16145: Fix `Html` helper `checkboxList()`, `radioList()`, `renderSelectOptions()`, `dropDownList()`, `listBox()` methods to work properly with traversable selection (samdark)
|
- Bug #16145: Fix `Html` helper `checkboxList()`, `radioList()`, `renderSelectOptions()`, `dropDownList()`, `listBox()` methods to work properly with traversable selection (samdark)
|
||||||
- Bug #17797: Fix for `activeListInput` options (alex-code)
|
- Bug #17797: Fix for `activeListInput` options (alex-code)
|
||||||
|
@ -147,6 +147,9 @@ class Controller extends \yii\base\Controller
|
|||||||
case 'float':
|
case 'float':
|
||||||
$params[$name] = filter_var($params[$name], FILTER_VALIDATE_FLOAT, FILTER_NULL_ON_FAILURE);
|
$params[$name] = filter_var($params[$name], FILTER_VALIDATE_FLOAT, FILTER_NULL_ON_FAILURE);
|
||||||
break;
|
break;
|
||||||
|
case 'bool':
|
||||||
|
$params[$name] = filter_var($params[$name], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if ($params[$name] === null) {
|
if ($params[$name] === null) {
|
||||||
$isValid = false;
|
$isValid = false;
|
||||||
|
@ -59,10 +59,12 @@ class ControllerTest extends TestCase
|
|||||||
|
|
||||||
$aksi1 = new InlineAction('aksi1', $this->controller, 'actionAksi1');
|
$aksi1 = new InlineAction('aksi1', $this->controller, 'actionAksi1');
|
||||||
|
|
||||||
$params = ['foo' => '100', 'bar' => null];
|
$params = ['foo' => '100', 'bar' => null, 'true' => 'on', 'false' => 'false'];
|
||||||
list($foo, $bar) = $this->controller->bindActionParams($aksi1, $params);
|
list($foo, $bar, $true, $false) = $this->controller->bindActionParams($aksi1, $params);
|
||||||
$this->assertSame(100, $foo);
|
$this->assertSame(100, $foo);
|
||||||
$this->assertSame(null, $bar);
|
$this->assertSame(null, $bar);
|
||||||
|
$this->assertSame(true, $true);
|
||||||
|
$this->assertSame(false, $false);
|
||||||
|
|
||||||
$params = ['foo' => 'oops', 'bar' => null];
|
$params = ['foo' => 'oops', 'bar' => null];
|
||||||
$this->expectException('yii\web\BadRequestHttpException');
|
$this->expectException('yii\web\BadRequestHttpException');
|
||||||
|
@ -17,7 +17,7 @@ class FakePhp7Controller extends Controller
|
|||||||
{
|
{
|
||||||
public $enableCsrfValidation = false;
|
public $enableCsrfValidation = false;
|
||||||
|
|
||||||
public function actionAksi1(int $foo, float $bar = null)
|
public function actionAksi1(int $foo, float $bar = null, bool $true, bool $false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user