10000 minor #10780 Complete code example for "Adding validation" part (welc… · marcinowski/symfony-docs@a3ce949 · GitHub
[go: up one dir, main page]

Skip to content

Commit a3ce949

Browse files
committed
minor symfony#10780 Complete code example for "Adding validation" part (welcoMattic)
This PR was squashed before being merged into the 3.4 branch (closes symfony#10780). Discussion ---------- Complete code example for "Adding validation" part <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> This fix will avoid confusion for beginners Commits ------- 6abfc12 Complete code example for \"Adding validation\" part
2 parents 72f3470 + 6abfc12 commit a3ce949

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

form/without_class.rst

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,22 @@ but here's a short example::
8282
use Symfony\Component\Validator\Constraints\Length;
8383
use Symfony\Component\Validator\Constraints\NotBlank;
8484
use Symfony\Component\Form\Extension\Core\Type\TextType;
85+
use Symfony\Component\Form\FormBuilderInterface;
8586

86-
$builder
87-
->add('firstName', TextType::class, array(
88-
'constraints' => new Length(array('min' => 3)),
89-
))
90-
->add('lastName', TextType::class, array(
91-
'constraints' => array(
92-
new NotBlank(),
93-
new Length(array('min' => 3)),
94-
),
95-
))
96-
;
87+
public function buildForm(FormBuilderInterface $builder, array $options)
88+
{
89+
$builder
90+
->add('firstName', TextType::class, array(
91+
'constraints' => new Length(array('min' => 3)),
92+
))
93+
->add('lastName', TextType::class, array(
94+
'constraints' => array(
95+
new NotBlank(),
96+
new Length(array('min' => 3)),
97+
),
98+
))
99+
;
100+
}
97101

98102
.. tip::
99103

0 commit comments

Comments
 (0)
0