Displaying only certain fields of choice with SQLFORM(...) update

47 views
Skip to first unread message

mostwanted

unread,
Jan 28, 2020, 5:29:49 AM1/28/20
to web2py-users
I was wondering if there is a way to show the SQLFORM() with only certain fields for the user during a form update & not show all the fields. SQLFORM.grid(...) has the field=None argument which enables one to select the fields to be displayed in the view, is there something like that for SQLFORM(....)?
I have some fields which only do calculations in my db tables & those are the fields I wanna hide during updates.

Regards;

Mostwanted

António Ramos

unread,
Jan 28, 2020, 5:50:31 AM1/28/20
to web...@googlegroups.com
Look in the docs ....

in your controller before showing your form,

db.yourtable.yourfield.readable=False!!! 

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/281ed3a3-66df-4eae-8768-1b9618c6093a%40googlegroups.com.

mostwanted

unread,
Jan 28, 2020, 8:21:04 AM1/28/20
to web2py-users
I did employ this method (db.quotation.beforeVat.readable=False!!! ) in my controller but it didnt respond, its actually the first thing i tried! Its just that i was hoping SQLFORM() may have some helpers as part of its signature that i dont know about that I could use.


On Tuesday, January 28, 2020 at 12:50:31 PM UTC+2, Ramos wrote:
Look in the docs ....

in your controller before showing your form,

db.yourtable.yourfield.readable=False!!! 

Em ter., 28 de jan. de 2020 às 10:29, mostwanted <godir...@gmail.com> escreveu:
I was wondering if there is a way to show the SQLFORM() with only certain fields for the user during a form update & not show all the fields. SQLFORM.grid(...) has the field=None argument which enables one to select the fields to be displayed in the view, is there something like that for SQLFORM(....)?
I have some fields which only do calculations in my db tables & those are the fields I wanna hide during updates.

Regards;

Mostwanted

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 web...@googlegroups.com.

António Ramos

unread,
Jan 28, 2020, 8:49:02 AM1/28/20
to web...@googlegroups.com
did you also tried writable=False 
When a field is marked with writable=False, the field is not shown in create forms, and it is shown readonly in update forms. If a field is marked as writable=False and readable=False, then the field is not shown at all, not even in update forms. 

db.table.var.readable= db.table.var.writable=False 

To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/0320799e-d6df-4e35-880e-26b902511278%40googlegroups.com.

John Bannister

unread,
Jan 28, 2020, 9:19:42 AM1/28/20
to web...@googlegroups.com

If you don’t want the field to be displayed in the SQLFORM() you need to set as follows:

db.table.fieldname.readable = db.table.fieldname.writable=False before the form initialisation.

 

So something like :-

db.dog.owner.readable=db.dog.owner.writable=False

form = SQLFORM(db.dog)

if form.process().accepted:

                …..

                ….

return dict(form=form)

mostwanted

unread,
Jan 29, 2020, 12:38:04 AM1/29/20
to web2py-users
Thank you, I overlooked that.

mostwanted

unread,
Jan 29, 2020, 12:38:30 AM1/29/20
to web2py-users
Thanks

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 web...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages