I have a custom form on my site, and I want to attach a reCaptcha to it. I wasn't successful using the Drupal 7 code for this. Suggestions? This is the Drupal 7 code I'm using:

$form['recaptcha'] = array(
  '#type' => 'recaptcha'

Use the following (after installing the reCaptcha module):

$form['captcha'] = array(
  '#type' => 'captcha',
  '#captcha_type' => 'recaptcha/reCAPTCHA',
  • And how to show the inline error for captcha. For ex: Just below the captcha field? Jun 12 '19 at 19:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.