Hi all, Symfony2 newbie here. I am attempting to get basic form validation working. The form is always valid, even when I violate the rules of the validation.yml. Any ideas?
app/config/config.php: validation: { enabled: true, annotations: true } controller: public function saveLoginAction() { $user = new User(); $form = LoginForm::create($this->get('form.context'), 'login'); $form->bind($this->get('request'), $user); if ($form->isValid()) { error_log('valid'); $em = $this->get('doctrine.orm.entity_manager'); $em->persist($user); $em->flush(); } else { error_log('not valid'); } return new RedirectResponse($this->generateUrl('hello')); } } form class: class LoginForm extends Form { protected function configure() { $this->add(new TextField('username', array( 'max_length' => 20, 'required' => 1, ))); } } src/Candy/MyFirstBundle/Resources/config/validation.yml: Candy\MyFirstBundle\User: properties: username: - minLength: 3 index.html.twig: {% extends '::layout.html.twig' %} {% block body %} Hello {{ name }} <br /> {% for user in users %} {{ user.username }}<br /> {% endfor %} <br /> <br /> {% block content %} <form action="saveLogin" method="post"> {{ form_field(form) }} <input type="submit" value="add" /> </form> {% endblock %} {% endblock %} -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en