Instead of this:
form = SQLFORM(db.syntable)
form.vars.phrase = word
#form.vars.syns = '|'+'|'.join(wordlist)+'|'
form.vars.syns = wordlist
if form.accepts(request.vars, session):
redirect(URL('test',args=myid))
do
db.syntable.phrase.default = word
db.syntable.syns.default = wordlist
form = SQLFORM(db.syntable)
if form.accepts(request.vars, session):
redirect(URL('test',args=myid))
There should be no '|' in your code.
On Oct 6, 8:54 am, Chuck Paulson <[email protected]> wrote:
> I am new to web2py and am writing my first app. I would like to pre-
> populate an SQLFORM field of type list:string with a list of strings
> and then display the form. The problem is that the syns always
> displays a one text box with a string that is either values separated
> by '|' or values or a string representation of a list.
>
> However, if I display a row already in the database with
> crud.update(), the list:string field is represented by a list of text
> fields, one per value, which is what I want. Is there a way to pre-
> populate the list:string field so it shows a list of text fields, one
> per value? Thanks,
>
> Chuck Paulson
>
> db.define_table('syntable',
> Field('phrase', 'string'),
> Field('syns', 'list:string'))
>
> form = SQLFORM(db.syntable)
> form.vars.phrase = word
> #form.vars.syns = '|'+'|'.join(wordlist)+'|'
> form.vars.syns = wordlist
> if form.accepts(request.vars, session):
> redirect(URL('test',args=myid))