I'm really missing a legend for the fieldset that CAPTCHA generates. Is there any way to add it as an option in the module or to do it from template.php?

Comments

soxofaan’s picture

Status: Active » Fixed

I'm not sure what you are talking about.

With the option "Add a description to the CAPTCHA" you can add a description to the fieldset.

If you are talking about a HTML-legend on a fieldset, then there should be a legend "CAPTCHA" by default. This is not configurable through the CAPTCHA admin interface.

However, in the CAPTCHA 6.x-2.x branch, the whole CAPTCHA widget (and optional fieldset) is rendered with a theme function (see captcha.module around line 265):

/**
 * Theme function for a CAPTCHA element.
 *
 * Render it in a fieldset if a description of the CAPTCHA
 * is available. Render it as is otherwise.
 */
function theme_captcha($element) {
  if (!empty($element['#description']) && isset($element['captcha_widgets'])) {
    $fieldset = array(
      '#type' => 'fieldset',
      '#title' => t('CAPTCHA'),
      '#description' => $element['#description'],
      '#children' => $element['#children'],
      '#attributes' => array('class' => 'captcha'),
    );
    return theme('fieldset', $fieldset);
  }
  else {
    return '<div class="captcha">'. $element['#children'] .'</div>';
  }
}

In your theme you can override this in the standard Drupal theming way, and change the legend ('#title' property) of the fieldset to your liking.

hope this helps.

Sidor’s picture

Ok - this is embarrassing. Actually the legend was there, but I had hidden it from my style sheet. Sorry about that :)

However, the reason to hiding it was that I didn't like the title, so your reply actually solved my problem. Thanks!

soxofaan’s picture

Title: Adding LEGEND to FIELDSET » CAPTCHA (fieldset) theming
Category: feature » support

you're welcome

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

vthirteen’s picture

Status: Closed (fixed) » Active

is there a way to change form label ("Math question" for instance) and text without changing module files?

i see that they're generated by function captcha_captcha in captcha.module but i think it's not themeable, isn't it? (although it is translatable).

thank you

soxofaan’s picture

Status: Active » Fixed

is there a way to change form label ("Math question" for instance) and text without changing module files?

There are several ways to achieve this (hook_form_alter with a custom module, custom theming), but the easiest is probably the string overrides module (or the locale module from core, when you are using multiple languages on your site)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Actually on my site it's hidden too, but I didn't hide it. Any clues how to activate "Add a description to the CAPTCHA"?
Thanks,
Jan

qmjeelani’s picture

I works for me. Thanks soxofaan

stephen ollman’s picture

Ok slightly different approach to this question.

At the moment the maths element is not correctly accessible in that the actual maths question 1+2 = is not part of the element thus is not associated with the input filed and not read out to the user.

How can I amend the form to include the maths question inside the elements?