$form = $this->container->get('form. factory')->createNamedBuilder( 'payment', 'form');
$form
->add('name', 'text', [
'attr' => ['placeholder' => "Name on Card"],
'constraints' => [
new Assert\NotBlank()
]
])
->add('card', 'text', [
'attr' => [
'placeholder' => "Card Number",
'maxlength' => 16
],
'constraints' => [
new Assert\NotBlank(),
new Assert\Length(16),
new Assert\Type(['type' => "numeric"])
]
])
->add('date', 'text', [
'attr' => [
'placeholder' => "MM / YY",
'autocomplete' => "off",
'maxlength' => 7
],
'constraints' => [
new Assert\NotBlank(),
new Assert\Regex(['pattern' => "/^\d{1,2}\s*\/\s*\d{2}$/"])
]
])
->add('cvc', 'text', [
'attr' => [
'placeholder' => "CVC",
'autocomplete' => "off",
'maxlength' => 3
],
'constraints' => [
new Assert\NotBlank(),
new Assert\Length(3),
new Assert\Type(['type' => "numeric"])
]
]);
Comments
Post a Comment