3

I add captcha field to form in this way

$form['captcha'] = array(
    '#type' => 'captcha',
    '#title' => 'Simple title',
    '#captcha_type' => 'captcha/Math',
    '#description' => 'Please solve it'
);

This element will be rendered as

<fieldset class="captcha form-wrapper"><legend><span class="fieldset-legend">CAPTCHA</span></legend><div class="fieldset-wrapper"><div class="fieldset-description">Please solve it</div><input type="hidden" name="captcha_sid" value="102">
<input type="hidden" name="captcha_token" value="bf6179f1c98e4291e1bb2e11c733d991">
<div class="form-item form-type-textfield form-item-captcha-response">
  <label for="edit-captcha-response">Math question <span class="form-required" title="Обов'язкове поле">*</span></label>
 <span class="field-prefix">20 + 0 = </span> <input type="text" id="edit-captcha-response" name="captcha_response" value="" size="4" maxlength="2" class="form-text required" autocomplete="off">
<div class="description">Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.</div>
</div>
</div></fieldset>

How to change this html template ?

1 Answer 1

2

I guess you could override theme_captcha. here is the code

function bartik_captcha($variables){
  $element = $variables['element'];
  $output='<h2>'.$element['#title'].'</h2>';
  $output.= drupal_render_children($element);
  return $output;
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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