codeigniter:fail to create captcha - codeigniter

I am using captcha and I want to create a captcha using the cpatcha helper!I read the user guide and write a piece of code,but it fails to create an captcha,also here is no error displayed on the page,so I just can't find where I am wrong,my code is as follows:
public function captcha(){
$this->load->helper('captcha');
$vals=array(
'word'=>'0123456789',
'img_path'=>base_url('asserts/cpatcha').'/',
'img_url'=>base_url('asserts/cpatcha').'/',
'img_width'=>150,
'img_height'=>30,
'expiration'=>7200
);
var_dump($vals);
$cap=create_captcha($vals);
var_dump($cap['image']);
}
as I print the two variables,the result displayed on the page is as follows:
array (size=6)
'word' => string '0123456789' (length=10)
'img_path' => string 'http://wrecruit.tudouya.com/asserts/cpatcha/' (length=44)
'img_url' => string 'http://wrecruit.tudouya.com/asserts/cpatcha/' (length=44)
'img_width' => int 150
'img_height' => int 30
'expiration' => int 7200
null

You may change
$cap=create_captcha();
to
$cap = create_captcha($vals);
and also change
var_dump($cap['image']);
to echo $cap['image'];

I solve this problem by myself and I post my solution at here,hope this can help others!
at first,the reason why the captcha can't display correctly due to the uncorrect config.it's this:'img_path'=>base_url('asserts/cpatcha').'/',.
I read the source code of captcha in ci and I find in the line 66-69,it will check if the img_path is a dir,just as follows:
if ( ! #is_dir($img_path))
{
return FALSE;
}
in my config,I set the img_path to "base_url('asserts/cpatcha').'/'",this is not a dir,so it will fail to create the captcha.
the way to solve this is just setting the correct path which will store the captcha image.
hope this can help you!

Related

yii2 ActiveRecord findBySql - Response content must not be an array Error

New to Yii2 nuances.
Just trying to get a return from a ActiveRecord query. I realize there is probably a much easier way to do this using Yii2 conventions
public function actionGet_permissions() {
$sql = 'select * from auth_item where owner_user_id IS NULL';
return Auth_Item::findBySql($sql)->all();
}
Errors "Response content must not be an array."
I think its pretty obvious the simple set of records I'm trying to return with this function. Any help is much appreciated, and let me know if any other information will help.
Why would findBySql not be allowed to return an array? I know I'm missing something simple here.
Thanks!
Edit 1:
Auth_Item::find()->where(['owner_user_id' => null])->all();
Returns the same error. And again, this seems like such a simple query.
Edit 2:
Stack Trace:
Invalid Parameter – yii\base\InvalidParamException
Response content must not be an array.
• 1. in C:\xampp\htdocs\clienti\vendor\yiisoft\yii2\web\Response.php at line 944
throw new InvalidConfigException("The '{$this->format}' response formatter is invalid. It must implement the ResponseFormatterInterface.");
}
} elseif ($this->format === self::FORMAT_RAW) {
$this->content = $this->data;
} else {
throw new InvalidConfigException("Unsupported response format: {$this->format}");
}
if (is_array($this->content)) {
throw new InvalidParamException("Response content must not be an array.");
} elseif (is_object($this->content)) {
if (method_exists($this->content, '__toString')) {
$this->content = $this->content->__toString();
} else {
throw new InvalidParamException("Response content must be a string or an object implementing __toString().");
}
}
}
}
• 2. in C:\xampp\htdocs\cli\vendor\yiisoft\yii2\web\Response.php – yii\web\Response::prepare() at line 312
• 3. in C:\xampp\htdocs\cli\vendor\yiisoft\yii2\base\Application.php – yii\web\Response::send() at line 381
• 4. in C:\xampp\htdocs\cli\frontend\web\index.php – yii\base\Application::run() at line 18
Edit 3:
Thanks for the help guys. Json encoding the result fixed the issue.
public function actionGet_permissions() {
$result = Auth_Item::find()->where(['owner_user_id' => NULL])->all();
return Json::encode($result);
}
You should use Yii2 features and modify response format.
Default response format is HTML, that's why you have the following error :
Response content must not be an array
You should simply try this :
public function actionGet_permissions()
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
return Auth_Item::find()->where(['owner_user_id' => NULL])->all();
}
Yii will automatically send http headers (previous answer will not) and encode your models.
Read more : http://www.yiiframework.com/doc-2.0/guide-runtime-responses.html
And if you want to use this response format in all your controllers, you could modify response config :
'response' => [
'format' => yii\web\Response::FORMAT_JSON,
'charset' => 'UTF-8',
],
Read more about yii\web\Response
Use Active Record:
public function actionGet_permissions() {
$result = Auth_Item::find()->where(['owner_user_id' => NULL])->all();
return Json::encode($result);
}
Better You make changes directly into your configuration file so that every request gets the proper json encoding.
'response' => [
'format' => yii\web\Response::FORMAT_JSON,
'charset' => 'UTF-8',
],
format json makes the variable post process automatically scalar by converting to json, whereas html response type does not convert arrays to scalars, therefore arrays have to have json response, I accidentally changed response type to HTML, but did forget to get rid of array structure at a particular place

gform_field_validation for URL input

I want to change the default validation message for all gravity forms for the URL input only. What is the best way of doing this with gform_field_validation or is there an alternative?
Yes gform_field_validation is the way to do this.
Here's some untested code, but I think it should work. Notice the FORMID and FIELDID that you should update with the appropriate values, not saying the regex will be exactly what you want, I just found it in a quick search here: What is the best regular expression to check if a string is a valid URL?
add_filter( 'gform_field_validation_FORMID_FIELDID', 'custom_url_validation', 10, 4 );
function custom_url_validation( $result, $value, $form, $field ) {
$url_regex = "/^[a-z](?:[-a-z0-9\+\.])*:(?:\/\/(?:(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!\$&'\(\)\*\+,;=:])*#)?(?:\[(?:(?:(?:[0-9a-f]{1,4}:){6}(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(?:\.(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3})|::(?:[0-9a-f]{1,4}:){5}(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(?:\.(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3})|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(?:\.(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3})|(?:[0-9a-f]{1,4}:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(?:\.(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3})|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(?:\.(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3})|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(?:\.(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3})|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(?:\.(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3})|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|v[0-9a-f]+[-a-z0-9\._~!\$&'\(\)\*\+,;=:]+)\]|(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(?:\.(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}|(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!\$&'\(\)\*\+,;=#])*)(?::[0-9]*)?(?:\/(?:(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!\$&'\(\)\*\+,;=:#]))*)*|\/(?:(?:(?:(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!\$&'\(\)\*\+,;=:#]))+)(?:\/(?:(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!\$&'\(\)\*\+,;=:#]))*)*)?|(?:(?:(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!\$&'\(\)\*\+,;=:#]))+)(?:\/(?:(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!\$&'\(\)\*\+,;=:#]))*)*|(?!(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!\$&'\(\)\*\+,;=:#])))(?:\?(?:(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!\$&'\(\)\*\+,;=:#])|[\x{E000}-\x{F8FF}\x{F0000}-\x{FFFFD}|\x{100000}-\x{10FFFD}\/\?])*)?(?:\#(?:(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!\$&'\(\)\*\+,;=:#])|[\/\?])*)?$/i";
if ( !preg_match( $url_regex, $value) ) {
$result['is_valid'] = false;
$result['message'] = 'Please enter a valid url!';
}
return $result;
}

Active Record Delete works false

I try to delete entries in the database with the active records of Yii. But I think it works really weird.
I want to delete all records of my table where vehicle_id = the given id and plug_id NOT IN (given string)
I tried a lot of ways and nothing worked but this
$query = "delete from `vehicle_details` where `vehicle_id`= ".$vehicle->id." AND `plug_id` NOT IN (".implode(',', array_map(function($item) {
return $item->type;
}, $vehicleDetails->plug)).")";
$command = Yii::app()->db->createCommand($query);
$command->execute();
But why isn't this working???
VehicleDetail::model()->DeleteAllByAttributes(
array('vehicle_id' => $vehicle->id),
array('condition' => 'plug_id NOT IN (:ids)',
'params' => array('ids' => implode(',', array_map(function($item) {
return $item->type;
}, $vehicleDetails->plug)))));
Or this:
VehicleDetail::model()->deleteAll(' vehicle_id = :vehicleId AND plug_id NOT IN (:ids)', array('vehicleId' => $vehicle->id, 'ids' => implode(',', array_map(function($item) {
return $item->type;
}, $vehicleDetails->plug))));
But if I make and Find by attributes out of this query it works well and returns the correct data.
I hope you can explain it to me.
Your code does not work because of wrong arguments passed in the methods. Problems occur when YII tries to build CDbCriteria object using your array arguments. Fortunetly, you can build a CDbCriteria by yourself and pass it into methods directly. Guess in this particular case it will be easier to use a CDbCriteria object to solve the issue.
$dbc = new CDbcriteria();
$dbc->condition = 'vehicle_id = :vehicleId';
$dbc->params = array(':vehicleId'=>$vehicle->id);
$dbc->addNotInCondition(
'plug_id',
array_map(
function($item) {
return $item->type;
},
$vehicleDetails->plug)
);
VehicleDetail::model()->deleteAll($dbc);
That is all you need.

How I can get the file id after upload a file to google drive?

I want to know the file id after upload. find it from file list, I think that isn't good idea and performance. so, How I can get the file id with good idea?
Thanks!
For example:
$file = new Google_Service_Drive_DriveFile();
$file->setName($fileTitle);
$result = $service->files->create(
$file,
array(
'data' => file_get_contents(FILE),
'mimeType' => 'application/octet-stream',
'uploadType' => 'multipart'
)
);
Var $result contain all information about uploaded file,so all you have to do is to display or use id.
echo 'Uploaded file id is '.$result['id'];
For someone coming from .Net background, use:
string fileId = request.ResponseBody.Id;
To get download link also, remember to set
request. Fields = "id, webContentLink";
string fileId = request.ResponseBody.Id;
string downloadLink = request.ResponseBody.WebContentLink;
In order to get download link you will need to set shared permission to the uploaded file after uploading the file.
var permission = new Permission { AllowFileDiscovery = true, Type = "anyone", Role = "reader" };
await driveService.Permissions.Create(permission, request.ResponseBody.Id).ExecuteAsync();

Zend Framework Validator Chain messages

Struggling to understand why my validator chain is showing the incorrect message for the value I type in.
Currently my model's code is making the incorrect message appear when I type in non-identical passwords instead of just the expected 3rd message ('Please retype password between 8-25 alphanumeric characters and matching the first password' when expecting 'Retyped password must match first.') when i type in mismatched passwords of 8 -25 characters long.
$password2 is the one giving issues
Also unsure if the indentical validator is working due to this problem.
Zend Framework version 1.11
Specific code chunk related to above
$password2 = new Zend_Form_Element_Password('password2');
$password2->setAttrib('size', 25);
$password2->setRequired(true);
$validatorChain2 = new Zend_Validate();
$validatorChain2->addValidator(new Zend_Validate_StringLength(array('min' => 8,'max' => 25)), true);
$validatorChain2->addValidator(new Zend_Validate_Alnum(false), true);
$validatorChain2->addValidator(new Zend_Validate_Identical('password1'), true);
$password2->addValidator($validatorChain2);
$password2->addErrorMessage('Please retype password between 8-25 alphanumeric characters and matching the first password');
$password2->addErrorMessage('Passwords can only be alphanumeric characters.');
$password2->addErrorMessage('Retyped password must match first.');
Full model code listing
class Application_Model_RegisterNewAccount extends Zend_Form
{
public function __construct($options = null)
{
// TODO: The errors are been grouped together at the top of the page now but the original error messages below each field need to be removed
parent::__construct($options);
$this->setName('newaccountregistration');
$this->setMethod('post');
$this->setAction($options['action']); // Variable action passed via parameter array for argument 'action'
$email = new Zend_Form_Element_Text('email'); // Create form text field
$email->setAttrib('size', 75); // Set for, element max size/length
$email->setRequired(true); // Make this field a required item
$validator_email = new Zend_Validate_EmailAddress();
$email->addValidator($validator_email); // Set validator type and minimum and maximum size required
$email->addErrorMessage('Please provide a valid email address');
$firstname = new Zend_Form_Element_Text('firstname');
$firstname->setAttrib('size', 35);
$firstname->setRequired(true);
$validator_firstname = new Zend_Validate_StringLength(array(1,35));
$firstname->addValidator($validator_firstname);
$firstname->addErrorMessage('Please provide your first name between 1-35 characters');
$surname = new Zend_Form_Element_Text('surname');
$surname->setAttrib('size', 35);
$surname->setRequired(true);
$validator_surname = new Zend_Validate_StringLength(array(1,35));
$surname->addValidator($validator_surname);
$surname->addErrorMessage('Please provide your first name between 1-35 characters');
$password1 = new Zend_Form_Element_Password('password1');
$password1->setAttrib('size', 25);
$password1->setRequired(true);
$validatorChain1 = new Zend_Validate();
$validatorChain1->addValidator(new Zend_Validate_StringLength(array('min' => 8,'max' => 25)), true);
$validatorChain1->addValidator(new Zend_Validate_Alnum(false), true);
$password1->addValidator($validatorChain1);
$password1->addErrorMessage('Please provide a password between 8-25 alphanumeric characters');
$password1->addErrorMessage('Passwords can only be alphanumeric characters.');
$password2 = new Zend_Form_Element_Password('password2');
$password2->setAttrib('size', 25);
$password2->setRequired(true);
$validatorChain2 = new Zend_Validate();
$validatorChain2->addValidator(new Zend_Validate_StringLength(array('min' => 8,'max' => 25)), true);
$validatorChain2->addValidator(new Zend_Validate_Alnum(false), true);
$validatorChain2->addValidator(new Zend_Validate_Identical('password1'), true);
$password2->addValidator($validatorChain2);
$password2->addErrorMessage('Please retype password between 8-25 alphanumeric characters and matching the first password');
$password2->addErrorMessage('Passwords can only be alphanumeric characters.');
$password2->addErrorMessage('Retyped password must match first.');
$submit = new Zend_Form_Element_Submit('submit'); // Added submit button
$submit->setLabel('Register');
$submit->removeDecorator('DtDdWrapper'); // Remove the default DD div wrapper
$this->setDecorators( array( array('ViewScript',
array('viewScript' => '_register.phtml')))); // The form html page
$this->addElements(array($email, $firstname, $surname, $password1, $password2, $submit)); // Add all the form elements
}
}
You should instantiate it like this...
$validatorChain2->addValidator(new Zend_Validate_Identical(array('token' => 'password1', 'messages' => ....)), true);

Resources