Commit d3ccb676 authored by dravenk's avatar dravenk Committed by Joshua Sedler
Browse files

Issue #3301409: The text of image_captcha can be modified with settings.

parent c19a9b2c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -14,3 +14,4 @@ image_captcha_bilinear_interpolation: 0
image_captcha_dot_noise: 0
image_captcha_line_noise: 0
image_captcha_noise_level: 5
image_captcha_text_refresh: 'Reload Captcha'
+3 −0
Original line number Diff line number Diff line
@@ -65,3 +65,6 @@ image_captcha.settings:
    image_captcha_noise_level:
      type: integer
      label: 'Noise level'
    image_captcha_text_refresh:
      type: label
      label: 'String with allowed characters'
+2 −2
Original line number Diff line number Diff line
@@ -379,9 +379,9 @@ function image_captcha_after_build_process($element) {
        $is_image_captcha = TRUE;
      }
    }

    $config = \Drupal::config('image_captcha.settings');
    if ($is_image_captcha && isset($element['captcha_widgets']['captcha_image'])) {
      $uri = Link::fromTextAndUrl(t('Get new captcha!'),
      $uri = Link::fromTextAndUrl($config->get('image_captcha_text_refresh'),
        new Url('image_captcha.refresh',
          ['form_id' => $form_id],
          ['attributes' => ['class' => ['reload-captcha']]]
+14 −0
Original line number Diff line number Diff line
@@ -247,6 +247,20 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
      '#default_value' => (int) $config->get('image_captcha_noise_level'),
    ];

    $form['image_captcha_text_settings'] = [
      '#type' => 'details',
      '#title' => $this->t('Text Content'),
      '#description' => $this->t('Customize image CAPTCHA text content.'),
    ];
    $form['image_captcha_text_settings']['image_captcha_text_refresh'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Refresh button text.'),
      '#description' => $this->t('Customize the refresh button text.'),
      '#default_value' => $config->get('image_captcha_text_refresh'),
      '#size' => 15,
      '#required' => TRUE,
    ];
    // Enter the characters shown in the image.
    return parent::buildForm($form, $form_state);
  }