Forums

How to change the error message? and to input 2 emails for to-field in email?

wlwan 12 Aug, 2015
Dears,
Questions 1
Would like to update the error message but fail to find the correct right to do so....

The message I would like to update mainly as below:
You have entered a wrong verification code!
Sorry, Your uploaded file type is not allowed.
(error show when upload file size is too big)

Did try to change
\administrator\components\com_chronoforms5\chronoforms\locales\en_gb\lang.php
> CF_CAPTCHA_ERROR_DESC
> CF_MAX_FILE_SIZE

\administrator\components\com_chronoforms5\chronoforms\actions\check_captcha\check_captcha.php

but still cant show the new changes.

Question 2
I would like to have a field for user to input emails (can be more than one, required field, need to input at least one email), these emails address will be used as the "To" field in the confirmation email. any idea how to do so? can i still use the validation in the system to check the email field as before?

Any hints for these 2 questions? Thanks for your time.

Best regards,
Wing
GreyHead 12 Aug, 2015
Answer
Hi Wing,

You have entered a wrong verification code! - in the Check Captcha action settings (for whichever captcha you are using)

Sorry, Your uploaded file type is not allowed. - in the Files Upload action.

You can set to email addresses using the Dynamic To Email box in the Email action. That certainly works for one address and I'm sure that we recently answered the question for more than one in the forums here.

Bob
wlwan 12 Aug, 2015
Dear Bob,
Thanks for your quick answer.

For the error message, I did something as below highlighted in red but fail:

<?php
/**
* ChronoCMS version 1.0
* Copyright (c) 2012 ChronoCMS.com, All rights reserved.
* Author: (ChronoCMS.com Team)
* license: Please read LICENSE.txt
* Visit http://www.ChronoCMS.com for regular updates and information.
**/
namespace GCore\Admin\Extensions\Chronoforms\Actions\CheckCaptcha;
/* @copyright:ChronoEngine.com @license:GPLv2 */defined('_JEXEC') or die('Restricted access');
defined("GCORE_SITE") or die;
Class CheckCaptcha extends \GCore\Admin\Extensions\Chronoforms\Action{
	static $title = 'Check Captcha';
	static $setup = array('simple' => array('title' => 'Captcha'));
	static $group = array('anti_spam' => 'Anti Spam');

	var $events = array('success' => 0, 'fail' => 0);

	var $defaults = array(
		'enabled' => 1,
		'error' => 'some more text here! You have entered a wrong verification code!',
	);

	function execute(&$form, $action_id){
		$config =  $form->actions_config[$action_id];
		$config = new \GCore\Libs\Parameter($config);
		if((bool)$config->get('enabled', 0) === false){
			return;
		}
		$result = \GCore\Helpers\Captcha\Captcha::check('captcha', $form->form['Form']['title'].'_captcha');
		if($result){
			$this->events['success'] = 1;
		}else{
			$this->events['fail'] = 1;
			$form->errors[] = $config->get('error', 'some more text here You have entered a wrong verification code!');
		}
	}

	public static function config(){
		echo \GCore\Helpers\Html::formStart('action_config check_captcha_action_config', 'check_captcha_action_config_{N}');
		echo \GCore\Helpers\Html::formSecStart();
		echo \GCore\Helpers\Html::formLine('Form[extras][actions_config][{N}][enabled]', array('type' => 'dropdown', 'label' => l_('CF_ENABLED'), 'options' => array(0 => l_('NO'), 1 => l_('YES')), 'sublabel' => l_('CF_CHECK_CAPTCHA_DESC')));
		echo \GCore\Helpers\Html::formLine('Form[extras][actions_config][{N}][error]', array('type' => 'text', 'label' => l_('CF_ERROR'), 'class' => 'XL', 'sublabel' => l_('CF_CAPTCHA_ERROR_DESC')));
		echo \GCore\Helpers\Html::formSecEnd();
		echo \GCore\Helpers\Html::formEnd();
	}
	
	public static function config_check($data = array()){
		$diags = array();
		$diags[l_('CF_DIAG_ENABLED')] = !empty($data['enabled']);
		return $diags;
	}
}


Did i do something wrong here?

Best regards,
Wing
GreyHead 12 Aug, 2015
Hi Wing,

Not wrong - just a complicated way to do it when you can set it in the action.

Bob
wlwan 12 Aug, 2015
Hi Bob,
O, somehow it doesn't work.... any idea? or I need to have some more setting afterward?

Wing
GreyHead 13 Aug, 2015
Hi Wing,

What doesn't work?

Bob
wlwan 13 Aug, 2015
Dear Bob,
For the error message: You have entered a wrong verification code!
> I go to \administrator\components\com_chronoforms5\chronoforms\actions\check_captcha\check_captcha.php
and do the changes as below:
var $defaults = array(
  'enabled' => 1,
  'error' => 'New Error Message! You have entered a wrong verification code!',
 );


and
if($result){
   $this->events['success'] = 1;
  }else{
   $this->events['fail'] = 1;
   $form->errors[] = $config->get('error', 'New Error Message! You have entered a wrong verification code!');
  }


But the new error message not show @front end. 😟

Wing
GreyHead 13 Aug, 2015
Hi Wing,

Then please try changing it in the action settings as I suggested and leave the ChronoForms code unchanged.

Bob
This topic is locked and no more replies can be posted.