Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
systems:yii2:email_tools [2018/05/10 16:49] smayr [Setup Captcha] |
systems:yii2:email_tools [2018/05/14 11:08] (current) smayr [Setup Captcha] |
||
---|---|---|---|
Line 146: | Line 146: | ||
<?= $form-> | <?= $form-> | ||
<?= $form-> | <?= $form-> | ||
- | <!-- // To regenerate new captcha after each refresh, call getVerifyCode(). | + | |
- | | + | |
- | --> | + | |
- | <? | + | // See: http:// |
+ | $this-> | ||
+ | | ||
<?= $form-> | <?= $form-> | ||
' | ' | ||
Line 442: | Line 444: | ||
== Setup Captcha == | == Setup Captcha == | ||
+ | |||
+ | '' | ||
In controller' | In controller' | ||
Line 506: | Line 510: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | In model using the captcha, add '' | ||
+ | <code php> | ||
+ | /** | ||
+ | * ContactForm is the model behind the contact form. | ||
+ | */ | ||
+ | class ContactForm extends Model | ||
+ | { | ||
+ | public $name; | ||
+ | public $email; | ||
+ | public $subject; | ||
+ | public $body; | ||
+ | public $verifyCode; | ||
+ | |||
+ | /** | ||
+ | * @return array the validation rules. | ||
+ | */ | ||
+ | public function rules() | ||
+ | { | ||
+ | return [ | ||
+ | // name, email, subject and body are required | ||
+ | [[' | ||
+ | // email has to be a valid email address | ||
+ | [' | ||
+ | // verifyCode needs to be entered correctly | ||
+ | [' | ||
+ | ]; | ||
+ | } | ||
+ | | ||
+ | //... | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | In form view using the captcha, add '' | ||
+ | <code php> | ||
+ | <? | ||
+ | // To regenerate new captcha after each refresh, call getVerifyCode(). | ||
+ | // See: http:// | ||
+ | | ||
+ | ?> | ||
+ | <?= $form-> | ||
+ | ' | ||
+ | ' | ||
+ | ]) ?> | ||
+ | </ | ||
+ | |||
+ | See more: | ||
+ | * [[https:// |