/** * [onPreSubmit description] * @param FormEvent $event [description] * @return [type] [description] */ function onPreSubmit(FormEvent $event) { $data = $event->getdata(); $form = $event->getForm(); $good = $this->getCurrentUser()->getPassword(); $password = $this->encoder->encodePassword($this->getCurrentUser(), $data['oldPassword']); if ($password != $good || $data['oldPassword'] == '') { $form->add('oldPassword', 'password', array('label' => 'form.security.field.old', 'attr' => array('class' => 'form-control'), 'constraints' => array(new EqualTo(array('value' => $good, 'message' => 'form.security.field.old')), new NotBlank(array())))); } }