[web2py] Re: contains return no rows of field list:string
I am building some .factory forms with list:string types and took me a time to realize the enter key needed to add new strings. I think that this is confusing, since the enter key is used in other fields to submit the form. I guess that changing this behavior would break apps that were built that way. Maybe it's possible to add an alternative widget for accepting multiple strings in the same input box?. If I recall correctly, Massimo used a very nice widget for adding tags a the same place, but it belive it's not available by default. El domingo, 15 de enero de 2012 14:33:15 UTC-3, howesc escribió: in the crud form you by default see a single input box for the list of strings right? type the first string, press enter, and a new input box should appear, type the next string and so on. the default widget for list strings has a bunch of keyboard actions to create the list items, but i found it not completely intuitive (i don't have real constructive suggestions for it so i haven't said much about it yet). cfh
[web2py] Re: contains return no rows of field list:string
Thank you Denes. I understood and this works fine at shell. At web-application, I use the below code, form = crud.create(db.entries, next = URL('index')) This gets me a simple text field for the 'list:string' field and whatever I enter gets in as, 'one,two,three' I tried to enter ['one','two','three'] and it gets in as a single string. so I'm still on zero. Can someone tell me how to handle (ie. whatever is entered gets in as individual strings and not as a single string) from the web-app. One option I can think of is to create a pain the form with individual fields and then process the form submission. But I hope I could handle this with crud, since it is so easy. Thank you, Joseph
[web2py] Re: contains return no rows of field list:string
in the crud form you by default see a single input box for the list of strings right? type the first string, press enter, and a new input box should appear, type the next string and so on. the default widget for list strings has a bunch of keyboard actions to create the list items, but i found it not completely intuitive (i don't have real constructive suggestions for it so i haven't said much about it yet). cfh
[web2py] Re: contains return no rows of field list:string
Thank you. It works. Just for completeness: I had designed a layout from scratch and hence had left out web2py_ajax.html. For this widget to work, it is essential that this file is included. Regards, Joseph
[web2py] Re: contains return no rows of field list:string
tags has to be a list of strings, try: db.entries.insert(title='hello',tags='one,two,three'.split(',')) or the equivalent: db.entries.insert(title='hello',tags=['one','two','three']) On Jan 14, 10:14 am, Joseph Jude ceph...@gmail.com wrote: I went into shell in a new web2py directory and tried the below. Surprisingly, I get empty output. Any explanations? python web2py.py -S init -M db.define_table('entries', Field('title', type='string'), Field('tags', 'list:string')) db.entries.insert(title='hello',tags='one,two,three') 1 t=db(db.entries.tags.contains('one')).select() t.as_list() []
[web2py] Re: contains return no rows of field list:string
Also, in the shell, you have to do db.commit() to commit db transactions (this is not necessary in a normal web request because the framework handles that automatically). See http://web2py.com/books/default/chapter/29/6#commit-and-rollback. Anthony On Saturday, January 14, 2012 11:52:01 AM UTC-5, DenesL wrote: tags has to be a list of strings, try: db.entries.insert(title='hello',tags='one,two,three'.split(',')) or the equivalent: db.entries.insert(title='hello',tags=['one','two','three']) On Jan 14, 10:14 am, Joseph Jude cep...@gmail.com wrote: I went into shell in a new web2py directory and tried the below. Surprisingly, I get empty output. Any explanations? python web2py.py -S init -M db.define_table('entries', Field('title', type='string'), Field('tags', 'list:string')) db.entries.insert(title='hello',tags='one,two,three') 1 t=db(db.entries.tags.contains('one')).select() t.as_list() []