Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
70 lines (49 sloc) 1.17 KB

Wordcha

Content

Usage

extensions:
    wordcha: Contributte\Wordcha\DI\WordchaExtension

Configuration

At the beginning you should pick the right datasource.

Numeric datasource

wordcha:
    datasource: numeric

Question datasource

wordcha:
    datasource: questions
    questions: 
        "Question a?": "a"
        "Question b?": "b"

Form

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;
}

Example

captcha

You can’t perform that action at this time.