thanks a lot massimo

I'm going to try it right now, and post the results on AlterEgo.

On Feb 26, 5:40 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> Mind that my example would not create a dropdown list. Only validate
> if the value if on the keys_table and eventually add it.
> You need a special type of dropdown including an insert field. You
> need to build that using JS or a widget. Look into the existing
> widgets in sqlhtml.py
>
> On Feb 26, 10:38 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > yes
>
> > class IS_IN_DB_OR_ADD:
> >     def __init__(self,db,table_and_field):
> >           self.db = db
> >           self.table,self.field = str(table_and_field).split('.')
> >     def __call__(self,value):
> >           if not self.db(self.db[self.table][self.field]==value):
> >                self.db[self.table].insert(**{self.field:value})
> >           return (value, None)
>
> > use it as
>
> > db.define_table('keys_table",SQLField('key_name'))
>
> > db.define_table("other_table",SQLField("mykey"))
>
> > db.other_table.mykey.requires=IS_NOT_EMPTY(), IS_IN_DB_OR_ADD
> > (db,'keys_table.key_name')
>
> > Hope it make sense.
>
> > (may contain a typo). If it works fine, could you post an AlterEgo
> > entry about this?
>
> > Massimo
>
> > On Feb 26, 10:03 am, kralin <andrea.pierle...@gmail.com> wrote:
>
> > > Hi everybody,
> > > this is my first post here.
> > > I'm learning to use web2py since a month now, and I really appreciate
> > > it's simplicity and speed of use.
> > > However, I've got a problem I'm not able to solve by myself.
> > > I read the manual and searched everywhere, but I still cannot find any
> > > hint. So you guys are my last hope...
>
> > > I'm building a simple database and I need to build an Input/modify
> > > mask with a contraint.
> > > In almost all the fields the user may be able to choose between
> > > selecting the values stored in an other table, or add a new value.
> > > This value should be added to the other table, and returned the next
> > > time.
> > > Is there a way to figure this out while maintaining a single input
> > > page?
> > > Maybe I'm asking something that is obvious to you, 'cause I'm sure I'm
> > > not the only one to have this problem. But I cannot find any example
> > > or documentation.
> > > I've got some strange ideas to solve this, but I was looking ad a
> > > simpler, web2py, way.
>
> > > Thanks in advance
--~--~---------~--~----~------------~-------~--~----~
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 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to