Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regex property to one of required option. #20212

Merged
merged 4 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Yii Framework 2 Change Log
- Bug #16116: Codeception: oci does not support enabling/disabling integrity check (@terabytesoftw)
- Bug #20191: Fix `ActiveRecord::getDirtyAttributes()` for JSON columns with multi-dimensional array values (brandonkelly)
- Bug #20175: Fix bad result for pagination when used with GridView (@lav45)
- Bug #20211: Add acceptable parameters to `MaskedInput::init()` method (alxlnk)


2.0.50 May 30, 2024
Expand Down
4 changes: 2 additions & 2 deletions framework/widgets/MaskedInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@
public function init()
{
parent::init();
if (empty($this->mask) && empty($this->clientOptions['alias'])) {
throw new InvalidConfigException("Either the 'mask' property or the 'clientOptions[\"alias\"]' property must be set.");
if (empty($this->mask) && empty($this->clientOptions['regex']) && empty($this->clientOptions['alias'])) {
throw new InvalidConfigException("Either the 'mask' property, 'clientOptions[\"regex\"]' or the 'clientOptions[\"alias\"]' property must be set.");

Check warning on line 136 in framework/widgets/MaskedInput.php

View check run for this annotation

Codecov / codecov/patch

framework/widgets/MaskedInput.php#L136

Added line #L136 was not covered by tests
}
}

Expand Down
7 changes: 7 additions & 0 deletions tests/framework/widgets/ActiveFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,13 @@ public function testInputOptionsTransferToWidget()
]);
$this->assertStringContainsString('placeholder="pholder_direct"', (string) $widget);

// use regex clientOptions instead mask
$widget = $this->activeField->widget(TestMaskedInput::className(), [
'options' => ['placeholder' => 'pholder_direct'],
'clientOptions' => ['regex' => '^.*$'],
]);
$this->assertStringContainsString('placeholder="pholder_direct"', (string) $widget);

// transfer options from ActiveField to widget
$this->activeField->inputOptions = ['placeholder' => 'pholder_input'];
$widget = $this->activeField->widget(TestMaskedInput::className(), [
Expand Down
Loading