web-dev-qa-db-ja.com

CAPTCHAモジュールのhtmlを別のモジュールに変更する方法は?

このようにフォームにキャプチャフィールドを追加します

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

この要素は次のようにレンダリングされます

<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>

このhtmlテンプレートを変更するにはどうすればよいですか?

3
Viktor

theme_captcha をオーバーライドできると思います。ここにコードがあります

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