PHP code example of contributte / wordcha

1. Go to this page and download the library: Download contributte/wordcha library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

contributte / wordcha example snippets


use Nette\Application\UI\Form;

protected function createComponentForm()
{
    $form = new Form();

    $form->addWordcha('wordcha')
        ->getQuestion()
        ->setRequired('Please answer antispam question');

    $form->addSubmit('send');

    $form->onValidate[] = function (Form $form) {
        if ($form['wordcha']->verify() !== TRUE) {
            $form->addError('Are you robot?');
        }
    };

    $form->onSuccess[] = function (Form $form) {
        dump($form['wordcha']);
    };

    return $form;
}