Password validation on insert / edit

QuestionsPassword validation on insert / edit
ITSpecialisst asked 8 years ago

I would like to add/edit users in a table calles "users". One field that has to be filled is the fild passord, which only exists ONCE in the db-table. Is there a way to have an additional field ("re-enter password") in the add7edit dialogue and to submit data only when both fields contain the same value?

Kind regards…
Michael

2 Answers
Abu Ghufran answered 8 years ago

Yes, you can have another virtual column (non db) that will be only shown in edit form.

$col = array();
$col["title"] = "Re-enter Password";
$col["name"] = "reenter_pass";
$col["width"] = "50";
$col["editable"] = true;

// only show on edit
$col["show"]["edit"] = true;
$col["show"]["list"] = false;
$col["show"]["add"] = false;

Next, in on_update event handler you can compare it's value with actual pass data and unset it so that it does not become part of update query:

// set 3rd param to true to run default update query after function
$e["on_update"] = array("update_client", null, true);

function update_client($data)
{
if ($data["params"]["pass"] != $data["params"]["reenter_pass"])
phpgrid_error("Passwords must match");

unset($data["params"]["reenter_pass"]);
}

Abu Ghufran answered 8 years ago

As your email is not in our CRM, it's good to tell that the custom events are available in full version.

Your Answer

5 + 8 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?