An ATK14 form field for protecting your forms against spam.
It uses https://www.google.com/recaptcha/intro/index.html
Just use the Composer:
cd path/to/your/atk14/project/
composer require atk14/recaptcha-field dev-master
ln -s ../../vendor/atk14/recaptcha-field/src/app/fields/recaptcha_field.php app/fields/recaptcha_field.php
You must define two constants in config/settings.php. Get their right values at https://www.google.com/recaptcha/admin#list
<?php
// file: config/settings.php
// ...
define("RECAPTCHA_SITE_KEY","fksjfu2094389SAKJDPOSAIIaskalkslamcbuyid");
define("RECAPTCHA_SECRET_KEY","pwofe994883eiDJKHFISIYTTSSSSSkfdt7poieqnx");
<?php
// file: app/forms/users/create_new_form.php
class CreateNewForm extends ApplicationForm{
function set_up(){
$this->add_field("captcha",new RecaptchaField(array(
"label" => "Spam protection"
)));
}
function clean(){
list($err,$values) = parent::clean();
// perhaps you may not want to have "spam" in the cleaned data
if(is_array($values)){ unset($values["spam"]); }
return array($err,$values);
}
}
The RecaptchaField is used in the registration form on ATK14 Forum for instance.
UrlField is free software distributed under the terms of the MIT license