Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5b8f853

Browse files
committed
minor#18889 Fix initialization of configurable options for the attribute (maMykola)
This PR was merged into the 5.4 branch.Discussion----------Fix initialization of configurable options for the attributeFixes#18868<!--If your pull request fixes a BUG, use the oldest maintained branch that containsthe bug (seehttps://symfony.com/releases for the list of maintained branches).If your pull request documents a NEW FEATURE, use the same Symfony branch wherethe feature was introduced (and `6.x` for features of unreleased versions).-->Commits-------92a6267 Fix initialization of configurable options for the attribute
2 parents7642001 +92a6267 commit5b8f853

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎validation/custom_constraint.rst‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@ First you need to create a Constraint class and extend :class:`Symfony\\Componen
4141
class ContainsAlphanumeric extends Constraint
4242
{
4343
public $message = 'The string "{{ string }}" contains an illegal character: it can only contain letters or numbers.';
44-
public $mode = 'strict'; // If the constraint has configuration options, define them as public properties
44+
public $mode = 'strict';
45+
46+
// all configurable options must be passed to the constructor
47+
public function __construct(string $mode = null, string $message = null, array $groups = null, $payload = null)
48+
{
49+
parent::__construct([], $groups, $payload);
50+
51+
$this->mode = $mode ?? $this->mode;
52+
$this->message = $message ?? $this->message;
53+
}
4554
}
4655
4756
Add ``@Annotation`` or ``#[\Attribute]`` to the constraint class if you want to

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp