I have the following code snippet: 

    form = SQLFORM.factory(Field('members', 'list:string',
        requires=IS_LIST_OF(IS_IN_DB(db, 'auth_user.email', '%(email)s')),
        ))
    form.vars.members = current_emails

This does not work.  if current_email is ['[email protected]'] for instance, then the 
field gets populated with the string '[[email protected]]' (including the square 
brackets!). 
I tried also: 

    form = SQLFORM.factory(Field('members', 'list:string',
        requires=IS_LIST_OF(IS_IN_DB(db, 'auth_user.email', '%(email)s')),
        default=current_emails
        ))

but this causes an even weirder problem.  If the user enters [email protected], and 
[email protected] as the two emails, assuming they do not belong to any user, then 
the form is redisplayed with a notice that there were errors, but on EACH 
of the two entries of the form, the single email addresses are BOTH 
replaced with the string "['[email protected]', '[email protected]']" . 

I guess this is a bug? 
How can I specify the initial value for a list:string field in a 
SQLFORM.factory form? 
Many thanks!

Luca

-- 



Reply via email to