Re: [web2py] SQLFORM labels

83 views
Skip to first unread message

Richard Vézina

unread,
Mar 19, 2013, 6:49:51 PM3/19/13
to web2py-users
The simpler is what you mention in model :

db.define_talbe(...
    Field(..., label=''),
    ...

You use this snippet to iterrate over your fields :
[ db[request.args(0)][field].label = '' for field in db[request.args(0)].fields ]

The other solution I see is custom form :


And it much more work and not pratical when you modify your app frequently during developpement because you have to think about modifying your custom form each time...

Hops it helps




On Tue, Mar 19, 2013 at 1:13 PM, carlo <syse...@gmail.com> wrote:
How can I get SQLFORM not showing any label?

I remembered labels=None but it's not working: only way I found is passing a labels dict with mykey='', not very practical.

By the way I am replicating the mywiki code from the manual: it coulf be upgraded because "page" and "document", from the error I got,  are now reserved keywords.

Carlo

--
 
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

carlo

unread,
Mar 20, 2013, 10:30:44 AM3/20/13
to web...@googlegroups.com
Thank you Richard,

I am not sure it is a good idea to render automatic labels in forms: especially with text areas they are annoying. I would maybe have preferred to get them the other way round, no labels unless explicitly declared. But that is just my personal preference, definitely not a big problem.

Richard Vézina

unread,
Mar 20, 2013, 12:30:10 PM3/20/13
to web2py-users
Carlo,

There is maybe other solution, those are just the one that come in mind...

I think you got a point about having a option in and out for labels thought

Richard

Anthony

unread,
Mar 20, 2013, 2:46:24 PM3/20/13
to web...@googlegroups.com
You might consider creating a custom formstyle function, modeled after this one, but without including the labels. You could then do SQLFORM(..., formstyle=myformstyle), or if you want it to apply to all forms in the app, somewhere in a model you could do SQLFORM.formstyles.table3cols = myformstyle. The table3cols formstyle is the default, so by changing the function associated with it, you will change the default.

Anthony

Carlo Bazzo

unread,
Mar 20, 2013, 6:16:24 PM3/20/13
to web...@googlegroups.com
Thank you Anthony,

very interesting solution, not aware of the formstyle parameter which looks very powerful.

carlo
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/WhRSjPn__g0/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

Derek

unread,
Mar 20, 2013, 6:27:43 PM3/20/13
to web...@googlegroups.com
pretty cool, I've been doing the CSS "nth-of-type" trick
Reply all
Reply to author
Forward
0 new messages