Skip to content
Closed
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
26 changes: 15 additions & 11 deletions form/without_class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,22 @@ but here's a short example::
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;

$builder
->add('firstName', TextType::class, array(
'constraints' => new Length(array('min' => 3)),
))
->add('lastName', TextType::class, array(
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
),
))
;
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('firstName', TextType::class, array(
'constraints' => new Length(array('min' => 3)),
))
->add('lastName', TextType::class, array(
'constraints' => array(
new NotBlank(),
new Length(array('min' => 3)),
),
))
;
}

.. tip::

Expand Down