<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;
class AddressBlockType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('street', TextType::class, [
'label' => false,
'required' => true,
'constraints' => [
new Assert\NotBlank(),
],
'attr' => [
'placeholder' => 'Strasse',
],
])
->add('zip', TextType::class, [
'label' => false,
'required' => true,
'constraints' => [
new Assert\NotBlank(),
new Assert\Length(['max' => 30]),
],
'attr' => [
'placeholder' => 'PLZ',
'maxlength' => '30',
],
])
->add('city', TextType::class, [
'label' => false,
'required' => true,
'constraints' => [
new Assert\NotBlank(),
],
'attr' => [
'placeholder' => 'Ort',
],
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
]);
}
}