Labels on table definition

6 views
Skip to first unread message

mfolmos

unread,
Jan 13, 2009, 7:16:54 PM1/13/09
to web2py Web Framework
My first post in the group:

I think if web2py have something like this or can be implemented:
db.define_table('puppy',
SQLField('name',label='A puppy'),
SQLField('image','upload', label='Photo'))


Would be grat, this is for Not having to write:
db.puppy.name.label = "A puppy"
db.puppy.image.label = "Photo"

and the forms created with SQLForm() set automaticaly the labels and
if not labels defined, the actual behaviour

Thanks in advance

Mauricio

mfolmos

unread,
Jan 13, 2009, 8:48:36 PM1/13/09
to web2py Web Framework
I answer myself: RTFM
a=SQLField
(name,'string',length=32,required=False,default=None,requires=IS_NOT_EMPTY
(),notnull=False,
unique=False,uploadfield=None,widget=None, label=None)

Why doesn't put this on the cookbook or t2 manual with the examples?
taken from the t2.pdf

* models/db.py
1 db=SQLDB(’sqlite://storage.db’)

2 db.define_table(’puppy’,
3 SQLField(’name’),
4 SQLField(’image’,’upload’))
5 db.puppy.name.requires=IS_NOT_EMPTY()

Can be:
* models/db.py
1 db=SQLDB(’sqlite://storage.db’)

2 db.define_table(’puppy’,
3 SQLField(’name’,label="Puppy name"),
4 SQLField(’image’,’upload’,label="Photo"))
5 db.puppy.name.requires=IS_NOT_EMPTY()

Mauricio

mdipierro

unread,
Jan 13, 2009, 10:54:15 PM1/13/09
to web2py Web Framework
It should. This is one of the many features that was added after the
manual was written. As soon as we finish integrating T2 into web2py,
the manual will be revised. Hopefuly in one month.

Massimo

Mike

unread,
Jan 14, 2009, 1:24:27 PM1/14/09
to web2py Web Framework
I recently tried this and it didn't seem to work...so I gather from
this thread that T2 is currently required to define a label in the
model but the plan is for this feature to migrate into the web2py
core?

Thanks for the clarification...

Mike
> > > Mauricio- Hide quoted text -
>
> - Show quoted text -

mdipierro

unread,
Jan 14, 2009, 2:21:03 PM1/14/09
to web2py Web Framework
should work without T2. which version do you have?
Massimo

vince

unread,
Jan 14, 2009, 8:18:42 PM1/14/09
to web2py Web Framework
can you make it work with SQLTABLE's header as well? thanks

-vince

Mike

unread,
Jan 14, 2009, 8:36:45 PM1/14/09
to web2py Web Framework
Hmm...it's working now. Thanks!

Mike
Reply all
Reply to author
Forward
0 new messages