We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Hello,

    Using a standard FormIt call, the recaptcha field stops the form from being submitted if it is not correctly filled in but the moment we use AjaxForm the other form fields validate but recaptcha is ignored.

    Anyone ever use the two and get it to work?
      • 46285
      • 2 Posts
      hi, add this code

      if(!empty($this->modx->placeholders[$plPrefix.'error.recaptcha'])) {
         $errors['recaptcha'] = $this->modx->placeholders[$plPrefix.'error.recaptcha'];
      }

      in function handleFormIt
      file ajaxform.class.php

      My handleFormIt

      public function handleFormIt(array $scriptProperties = array()) {
      		$plPrefix = isset($scriptProperties['placeholderPrefix'])
      			? $scriptProperties['placeholderPrefix']
      			: 'fi.';
      
      		$errors = array();
      		foreach ($scriptProperties['fields'] as $k => $v) {
      			if (isset($this->modx->placeholders[$plPrefix.'error.'.$k])) {
      				$errors[$k] = $this->modx->placeholders[$plPrefix.'error.'.$k];
      			}
      		}
      
              if(!empty($this->modx->placeholders[$plPrefix.'error.recaptcha'])) {
                  $errors['recaptcha'] = $this->modx->placeholders[$plPrefix.'error.recaptcha'];
              }
      
      		if (!empty($errors)) {
      			$message = !empty($this->modx->placeholders[$plPrefix.'validation_error_message'])
      				? $this->modx->placeholders[$plPrefix.'validation_error_message']
      				: 'af_err_has_errors';
      			$status = 'error';
      		}
      		else {
      			$message = isset($this->modx->placeholders[$plPrefix.'successMessage'])
      				? $this->modx->placeholders[$plPrefix.'successMessage']
      				: 'af_success_submit';
      			$status = 'success';
      		}
      
      		return $this->$status($message, $errors);
      	}