captcha() form()
The anti-bot check of a form: the captcha image with its input by default, or the widget of the form's driver; checked by the captcha validation rule.
form()->captcha($name = '', $desc = '', $extra = [], $replace = [])Options
| Option | Meaning |
|---|---|
$name | Default captcha. |
class, style, placeholder, size | Attributes of the input (image captcha). |
captcha_form | The form name of the anti-bot settings (driver per form); default the module of the request. |
Example
Code
return form()
->email()
->captcha();Notes
- The image comes from
/dynamic/captcha_image; the answer is kept in the session. - Validate with the
captcharule:validate(['captcha' => 'captcha']);captcha[contact]names the form. An empty captcha fails the form (before 2026-11-28 a rule withoutrequiredlet it pass). - Another driver (Turnstile, reCAPTCHA, hCaptcha, Friendly Captcha, ALTCHA) draws its widget in the same row: anti-bot setup.
See also: form/validate, demo:form/captcha, misc:anti_bot