this should be simple but it is not working right.   All i am trying
to do is insert form variables into the database and make sure
duplicates are not inserted.   I would imagine the controller is
bypassing the db.requires, but i am a newbie and don't understand why
it is being bypassed.   What is happening is that my controller inputs
the form.vars.name even if it is already in the database.   I know
that i can use the SQLFORM, but i am practicing the lower level form
stuff to get a better understanding of forms and databases.

Thanks in advance for any help,


Chawk

p.s.  Should i be adding something to my post to show that a question
is solved, like they do on stackoverflow?  i saw somebody do that on
this forum and did not know if I should be doing the same.

MODEL:

    db.define_table('president',
                    Field('name', 'string'))

    db.president.name.requires = IS_NOT_IN_DB(db, 'president.name')


CONTROLLER:

    def test():
    message = ""
        form = FORM('Join President?', INPUT(_name='join',
_type='radio'),
                    INPUT(_name="name"), INPUT(_type='submit'))
        if form.process().accepted:
            db.president.insert(name=form.vars.name)
        return dict(form=form, message=message)

VIEW:

{{=form}}
{{pass}}
{{=message}}

Reply via email to