Welcome Guest, Not a member yet? Register   Sign In
Callbacks and previous values
#1

[eluser]Kemik[/eluser]
Hello,

I'm making an edit profile page for my users and have two fields which must be unique to the user: email and username.

In my current system, if I only edit one of the fields (e.g. username) the other field gets marked as not unique as the callback detects the email value as already taken.

To get around this I want to pass two values for each field. One would be the posted value and one the original. This would allow me to check in the database if the posted value is unique, not including the original value.

Let me know if what I've said is confusing and I'll clear it up. If anyone has got around this problem themselves, please let me know what you did.
#2

[eluser]wiredesignz[/eluser]
I re-write the validation rule for editing.

for adding a new user I have default rules:
Code:
$rules['username'] => 'trim|required|callback_is_unique[username]';
$rules['email'] => 'trim|required|callback_is_unique[email]';

which I then re-write before editing with the same form:

Code:
$rules['username'] => '';

I disable the username input so it can't be changed. but email is_unique is still checked from the previous setting.

YMMV ... Just alter the rules for your situation.




Theme © iAndrew 2016 - Forum software by © MyBB