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

Commit552e7b4

Browse files
committed
minor#7664 Add an explanation about «constraints» validation (chindit, javiereguiluz)
This PR was submitted for the 3.2 branch but it was merged into the 2.7 branch instead (closes#7664).Discussion----------Add an explanation about «constraints» validationAdded an explanation about the use of «constraints» in Form Classes and the requirement of «ValidatorExtension» if «constraints» keyword is used.This is currently not explained in doc, nor in Forms, Validation, Custom validation or any other page.Commits-------c9f1b95 Rewords and minor fixescb6b2e6 Add an explanation about «constraints» validation
2 parents1851aa5 +c9f1b95 commit552e7b4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

‎validation.rst‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,29 @@ If you're ever unsure of how to specify an option, either check the API document
455455
for the constraint or play it safe by always passing in an array of options
456456
(the first method shown above).
457457

458+
Constraints in Form Classes
459+
---------------------------
460+
461+
Constraints can be defined while building the form via the ``constraints`` option
462+
of the form fields::
463+
464+
public function buildForm(FormBuilderInterface $builder, array $options)
465+
{
466+
$builder
467+
->add('myField', TextType::class, array(
468+
'required' => true,
469+
'constraints' => array(new Length(array('min' => 3)))
470+
))
471+
}
472+
473+
The ``constraints`` option is only available when adding the ValidatorExtention
474+
to the formBuilder::
475+
476+
Forms::createFormFactoryBuilder()
477+
->addExtension(new ValidatorExtension(Validation::createValidator()))
478+
->getFormFactory()
479+
;
480+
458481
..index::
459482
single: Validation; Constraint targets
460483

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp