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

Commitc9f1b95

Browse files
javiereguiluzxabbuh
authored andcommitted
Rewords and minor fixes
1 parentcb6b2e6 commitc9f1b95

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

‎validation.rst‎

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -455,27 +455,33 @@ 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-
..index::
459-
single: Validation; Constraint targets
460-
461-
.. _validator-constraint-targets:
462-
463-
Constraint in Form Classes
464-
------------------
458+
Constraints in Form Classes
459+
---------------------------
465460

466-
When creating your own form classes, you may want to add constraint directly intheformBuilder.
467-
This is done by simply adding them as a parameter in your field options::
461+
Constraints can be defined while building the form viathe``constraints`` option
462+
of the form fields::
468463

469464
public function buildForm(FormBuilderInterface $builder, array $options)
470465
{
471466
$builder
472-
->add('myField', TextType::class, ['required' => true, 'constraints' => [new Length(['min' => 3])]])
467+
->add('myField', TextType::class, array(
468+
'required' => true,
469+
'constraints' => array(new Length(array('min' => 3)))
470+
))
473471
}
474472

475-
Please note the *constraints* keyword will onlybeavailableif you have
476-
added the *ValidatorExtention*to the formBuilder::
473+
The ``constraints`` option is only availablewhen adding the ValidatorExtention
474+
to the formBuilder::
477475

478-
Forms::createFormFactoryBuilder()->addExtension(new ValidatorExtension(Validation::createValidator()))->getFormFactory();
476+
Forms::createFormFactoryBuilder()
477+
->addExtension(new ValidatorExtension(Validation::createValidator()))
478+
->getFormFactory()
479+
;
480+
481+
..index::
482+
single: Validation; Constraint targets
483+
484+
.. _validator-constraint-targets:
479485

480486
Constraint Targets
481487
------------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp