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

OptionMeaning
$nameDefault captcha.
class, style, placeholder, sizeAttributes of the input (image captcha).
captcha_formThe 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 captcha rule: validate(['captcha' => 'captcha']); captcha[contact] names the form. An empty captcha fails the form (before 2026-11-28 a rule without required let 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