I guess that in "Actually this does not happen with SQLFORM since it
is smart enough to figure out that the current record should be
included when enforcing
IS_NOT_IN_DB(...). ", 'included' should read 'excluded'.

On Nov 24, 5:56 am, mdipierro <[EMAIL PROTECTED]> wrote:
> Actually this does not happen with SQLFORM since it is smart enough to
> figure out that the current record should be included when enforcing
> IS_NOT_IN_DB(...).
>
> In your case I see you are using a normal FORM instead of SQLFORM. In
> this case the solution is
>
> IS_NOT_IN_DB(db(db.users.id!=user_id),'users.email')
>
> i.e. make sure not other use (but user_id) has this email.
>
> Massimo
>
> On Nov 23, 11:35 pm, voltron <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
>
> > I allow users to edit their account settings in a web application. One
> > of the fields is their email address. I put a constraint on the field
> > stating that it should never be empty, null and unique. I came across
> > the situation that a user might want to change her/his email address,
> > the problem is, using SQLFORM, the form and database validation kicks
> > in and notifies the user that the email exists already and cannot be
> > updated even though it is unique and belongs to the user as in:
>
> > # snippet
>
> >  TR(TD(T("Email"),           _class="label"), INPUT(_name="email",
> > _value = user[0].email,     _class = "text_input", requires=
> > [IS_NOT_EMPTY(), IS_NOT_IN_DB(db,'users.email'), IS_EMAIL()])),
>
> > form.components[0].components[1].components[1].components[0].attributes
> > ['requires'][1].error_message = T("This email address exists already,
> > please choose another")
>
> >  id=db.users.update(
> >                                email        = form.vars.email,
> >                                password     = form.vars.password
> >                                )
>
> > I could, just require that an email is given and not requesting it to
> > be unique, but I think that thats a security risk.
>
> > I would not like to make extensive and wasteful checks again just for
> > that field. Is there a clean way to allow a user to update her email
> > address only it it does not exist and even if it existed not complain
> > only if it belonged to the user in question before?
>
> > Thanks
>
> > Thaanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to