As long as the form is a SQLFORM (including Crud and SQLFORM.grid), then
yes, that should be the default behavior simply by specifying a list:string
type field. SQLFORM automatically uses the SQLFORM.widgets.list widget for
list:string and list:integer fields, and that widget includes the
Javascript to implement the behavior. If you view the page source in your
browser, you should see the Javascript code inserted right after the UL.
Anthony
On Tuesday, March 13, 2012 10:32:14 PM UTC-4, VP wrote:
>
> Anthony, maybe I didn't ask clearly. Here's the model:
>
> Bookmark = db.define_table(
> 'bookmark',
> Field('link','reference link',writable=False),
> Field('category',requires=IS_IN_SET(['work','personal'])),
> Field('tags','list:string'),
> auth.signature)
>
>
> I'm talking about field "tags"
>
> ----
> Here's view:
>
> {{extend 'layout.html'}}
>
> <h3>Bookmark for {{=url}}</h3>
>
> {{def show(rating,k):}}<strong>{{=rating.get(k,[0])[0]}}%</
> strong>{{return}}
> <div>
> Trustworthiness: {{show(rating,'1')}}
> Reliability: {{show(rating,'2')}}
> Privacy: {{show(rating,'3')}}
> Child safety: {{show(rating,'4')}}
> </div>
> <img src="{{=URL('default','download',args=link.screenshot)}}"
> align="right"/>
> {{=form}}
>
>
> ----
>
> I don't see anything special in view, but the field "tags"
> automatically adds a new text box for a new tag, after you enter a
> tag.
>
> How do I do this?
>
> This behavior isn't by default (I think).
>
> Thanks.
>
>
>
>
> On Mar 13, 8:26 pm, Anthony <[email protected]> wrote:
> > On Tuesday, March 13, 2012 9:17:06 PM UTC-4, VP wrote:
> >
> > > Also, I saw in the video the field tag of type "list:string" is
> > > presented nicely in view in the following way: after a new tag is
> > > entered, a new empty textbox is added so a new tag can be added. How
> > > is this done? (I don't think this is the default behavior).
> >
> > In SQLFORM, the list widget is assigned to list: type fields:
> http://code.google.com/p/web2py/source/browse/gluon/sqlhtml.py#873
> >
> > And the list widget includes Javascript to handle the inputs:
> http://code.google.com/p/web2py/source/browse/gluon/sqlhtml.py#234.
> >
> > Anthony