I'm trying to add EWZRecaptcha to my registration form. My registration form builder looks something like this:
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('username', 'text')
->add('password')
->add('recaptcha', 'ewz_recaptcha', array('property_path' => false));
}
public function getDefaultOptions(array $options)
{
return array(
'data_class' => 'Acme\MyBundle\Entity\User',
);
}
Now, how can I add the Recaptcha Constraint to the captcha field? I tried to add this to validation.yml:
namespaces:
RecaptchaBundle: EWZ\Bundle\RecaptchaBundle\Validator\Constraints\
Acme\MyBundle\Entity\User:
...
recaptcha:
- "RecaptchaBundle:True": ~
But I get Property recaptcha does not exists in class Acme\MyBundle\Entity\User
error.
If I remove array('property_path' => false)
from the recaptcha field's options, I get the error:
Neither property "recaptcha" nor method "getRecaptcha()" nor method "isRecaptcha()"
exists in class "Acme\MyBundle\Entity\User"
Any idea how to solve it? :)
mapped=false
should be used instead ofproperty_path=false
, see symfony.com/doc/current/reference/forms/types/… and symfony.com/doc/current/reference/forms/types/form.html#mapped, respectively. – Weasner