When Submitting Signup Form With A Required Field Blank Then 32 Bit Character Value Generated On Password Field

Hi All,

I am facing trouble to remove value from password field. When I submit signup form without entering one or more required field then its generate a 32 bit character value on password field. I want to see this field blank in that case.

With Thanks,

MRS

How and where is the password field being hashed?

If it’s in a custom validation rule, you could put a guard at the top of the validation method:




    if ($this->hasErrors())

        return;


    // Password hashing code



A common problem, but it has a simple solution: Do not try to use the same model attribute for two different purposes i.e. storing both user input for password and the hashed password from the database (as they are not the same data). Rename "password" column in your database to "password_hash" (or similar) and add a public property called "password" to your model. Use "password" to store and validate user input and "password_hash" to store the hashed value.

Hi All,

Thanks for your quick reply.

I solved this issue by following way-


if ($model->save()) {

  $this->redirect('/success!'); // redirect or whatever

} else {

  $model->password = ''; // if the save failed, clear out the password before re-rendering the form

}

With Thanks,

MRS