Worked like a charm thanks. :) Also taught me a few things heh ;) Btw, how was PyCon?
On Mar 29, 5:25 pm, mdipierro <[email protected]> wrote: > You can use > > class NameValidator: > def __init__(self,error_message='not in db'): > self.error_message=error_message > def __call__(self,name): > users=db(db.users.name==name).select() > if not users: return (name, self.error_message) > return (users[0].id,None) > def format(self,id) > return db.users[id].name > > db.mailbox.account_id.requires=NameValidator() > > In the page you may also need this: > <script> > $(document).ready(function() { $('#mailbox_account_id').attr > ('class','string'); }); > </script> > > Hope it makes sense. > > Massimo > > On Mar 29, 2:19 pm, TheDude <[email protected]> wrote: > > > Here's the code:http://pastie.org/private/wmow1xkoaov5ium6cgf8w > > > Here's the problem: > > ok now a new problem let's say im building a mailbox application (not > > like email like a private messaging system) and int he table mailbox I > > have account_id (which account its tied to) > > On the SQLFORM it shows Account ID: <input> (which i changed to > > Player:) but I want the Player: field to actually be tied to > > accounts.name rather than mailbox.account_id > > and then use my own function called lookup_name() that returns the ID > > of the account's name > > would it be best practice to do theid = lookup_name > > (request.post.account_id) db.mailbox.account_id.default = theid ? > > > Is there some kind of way to make it so SQLFORMS will do this > > automatically? I don't want that drop down box solution because when I > > have 100,000 user entries that would take a long time to load. :) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---

