<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;
class DemoRequestType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('institution', TextType::class, [
'label' => 'Institution',
'constraints' => [
new Assert\NotBlank(['message' => 'Please enter your institution name']),
new Assert\Length(['max' => 180]),
],
])
->add('role', ChoiceType::class, [
'label' => 'Role',
'choices' => [
'Executive Leadership' => 'Executive Leadership',
'Finance' => 'Finance',
'Institutional Research / Analytics' => 'Institutional Research / Analytics',
'IT / Data' => 'IT / Data',
'Enrollment / Admissions' => 'Enrollment / Admissions',
'Other' => 'Other',
],
'placeholder' => 'Select one',
'constraints' => [
new Assert\NotBlank(['message' => 'Please select your role']),
],
])
->add('name', TextType::class, [
'label' => 'Name',
'constraints' => [
new Assert\NotBlank(['message' => 'Please enter your name']),
new Assert\Length(['max' => 120]),
],
])
->add('email', EmailType::class, [
'label' => 'Email',
'constraints' => [
new Assert\NotBlank(['message' => 'Please enter your email']),
new Assert\Email(['message' => 'Please enter a valid email address']),
new Assert\Length(['max' => 180]),
],
])
->add('phone', TextType::class, [
'label' => 'Phone (optional)',
'required' => false,
'constraints' => [
new Assert\Length(['max' => 40]),
],
])
->add('message', TextareaType::class, [
'label' => 'What would you like to see in the demo?',
'attr' => ['rows' => 6],
'required' => false,
'constraints' => [
new Assert\Length(['max' => 4000]),
],
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'csrf_protection' => true,
]);
}
}