Commit c9c945b2 by Lech Sawon

validation in form

parent 1fc7c797
......@@ -4,15 +4,24 @@ namespace App\Form;
use App\Entity\Room;
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\Length;
use Symfony\Component\Validator\Constraints\Regex;
class RoomType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name')
->add('name', TextType::class, [
'required' => true,
'constraints' => [
new Length(['min' => 3]),
new Regex('/^[a-zA-Z0-9]*$/')
],
])
;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment