登録フォームにEWZRecaptchaを追加しようとしています。私の登録フォームビルダーは次のようになります。
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',
);
}
では、キャプチャフィールドにRecaptcha制約を追加するにはどうすればよいですか?これをvalidation.ymlに追加しようとしました:
namespaces:
RecaptchaBundle: EWZ\Bundle\RecaptchaBundle\Validator\Constraints\
Acme\MyBundle\Entity\User:
...
recaptcha:
- "RecaptchaBundle:True": ~
しかし、Property recaptcha does not exists in class Acme\MyBundle\Entity\User
エラーが発生します。
array('property_path' => false)
reCAPTCHAフィールドのオプションから削除すると、次のエラーが発生します。
Neither property "recaptcha" nor method "getRecaptcha()" nor method "isRecaptcha()"
exists in class "Acme\MyBundle\Entity\User"
それを解決する方法はありますか?:)