⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Confirm Password always not match with Password



lordlaw

lordlaw
  • profile picture
  • Member

Posted 17 January 2016 - 04:36 AM

i had a membership form

with user creating new member with their new password.

 

so in the form will have Password and Confirm Password field.

 

in add form, they are working fine

 

but when it come to edit

Confirm password always not match with Password, although i had clearly input the correct for both fields.


if($crud->getState() == "edit") {
    $crud->field_type('Username', 'readonly');
    $crud->callback_edit_field('Password', function($value){
	return '<input type="password" maxlength="128" value="" name="Password" class="form-control" id="field-Password">';
    });
}

if($crud->getState() == "insert_validation") {
    $crud->set_rules('Password', 'Password', 'required');
    $crud->set_rules("CPassword", 'Confirm Password', "trim|required|matches[Password]");
} else if($crud->getState() == "update_validation") {
    $crud->set_rules("CPassword", 'Confirm Password', "matches[Password]");
}

any advices ?

 

Thanks.


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 19 January 2016 - 22:55 PM

Hi,

 

What here is happening - in crud - u trying to do a validation on a field that dose not exists ...

check your own code - you are generating the password field on the fly - only when it is in state - edit.

The same will not be available technically on next call when update_validation is happening.

Thats where i will recommend - u set a psuedo field of nPassword / cPassword .. 

callback before update ... check if the nPassword field is filled up with value or not..

if yes - append password field as index to the array ... and return the same (of course - add or not .. u have to unset nPassword / cPassword before returning to avoid any sort of errors)

 

Hope this fixes your requirement..

 

Happy GCing :)