jbennecker / silverstripe-recaptcha
此包已弃用且不再维护。未建议替代包。
SilverStripe模块用于ReCaptcha 2.0垃圾邮件保护
v4.0.0
2019-01-22 14:20 UTC
Requires
- php: >=7.0.0
- silverstripe/cms: ^4
- silverstripe/framework: ^4
This package is auto-updated.
Last update: 2022-03-17 07:42:11 UTC
README
简介
此模块为SilverStripe 4.x添加了RecaptchaField,您可以在自定义表单中使用它。
安装
composer require jbennecker/silverstripe-recaptcha
使用方法
将您的密钥放入app/_config/app.yml
jbennecker\recaptcha\Forms\RecaptchaField: public_api_key: "public key" private_api_key: "private key"
然后您可以在表单中使用此字段。
public function HelloForm() { $fields = new FieldList( TextField::create('Name', _t('HelloForm.Name', 'Name')), TextField::create('Email', _t('HelloForm.Email', 'E-Mail')), TextareaField::create('Nachricht', _t('HelloForm.Nachricht', 'Nachricht')), RecaptchaField::create('recaptcha') // <--- add this ); $actions = new FieldList( FormAction::create('doSayHello')->setTitle(_t('HelloForm.Submit', 'Senden')) ); $required = new RequiredFields('Name', 'Email', 'Nachricht'); $form = new Form($this, 'HelloForm', $fields, $actions, $required); return $form; }