customizing SQLFORM

64 views
Skip to first unread message

Maurice Waka

unread,
Mar 18, 2020, 8:51:27 AM3/18/20
to web2py-users
Hello,

I'm trying to customize the SQLFORM to look like textarea/input....with text area floating left and submit button to the right and not bottom. I'm using the LOAD signature.

I also want to hide the filed name (labelled as Questions see attached).

Currently with this code, I cant hide the field name and I cant find a way to float the submit button to the right. 

Attached is how the form looks like.

def post():
   
#db.posts.message.readable = False#Not working with this code
   
return dict(form=SQLFORM(db.posts, readable=False).process(),
        posts
=db(db.posts.author == auth.user.id).select() )


View page...post.load
<div class="bottom_wrapper">
{{=form}}
</div>

Screenshot from 2020-03-18 15-48-02.png

Javier Pepe

unread,
Mar 18, 2020, 9:00:51 AM3/18/20
to web...@googlegroups.com
Hi

You can try with this

db.posts.question.label = ' '

label attr replace field name



--
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/c8216348-8f12-4e8e-90c2-7e4ef9a482be%40googlegroups.com.

Maurice Waka

unread,
Mar 18, 2020, 9:09:17 AM3/18/20
to web2py-users
Thanks.
I put the code in the model.py code. It works.

How about float button to right?

Regards

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/m9jMXz52fZg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/CAHxJ-7oD-q_bewVyZbcViPAeKUx4kzy%2BMbCTbU%2B5_BA1a%2BSSew%40mail.gmail.com.

Javier Pepe

unread,
Mar 18, 2020, 9:13:58 AM3/18/20
to web...@googlegroups.com
in the manual 

{{=form.custom.begin}}
<div>{{=form.custom.widget.question}}{{=form.custom.submit}}</div>
{{=form.custom.end}}

Maurice Waka

unread,
Mar 18, 2020, 9:23:15 AM3/18/20
to web2py-users
I'm getting a none value. See attached.

Screenshot from 2020-03-18 16-22-11.png

Maurice Waka

unread,
Mar 18, 2020, 9:24:29 AM3/18/20
to web2py-users
This is my code in the model.py

db.define_table('posts',
                Field('author', 'reference auth_user', default=auth.user_id, writable=False, readable=False),
                Field("message", 'string', requires=IS_NOT_EMPTY(), length=512, label=T('questions'),widget=widget(_placeholder='Type your question here',)),
                auth.signature
                )

Maurice Waka

unread,
Mar 18, 2020, 9:35:43 AM3/18/20
to web2py-users
I got something but still not working:

buttons = [INPUT(_type="submit"),INPUT(_type="button",_onclick="history.go(-1);return False")]

Javier Pepe

unread,
Mar 18, 2020, 9:40:57 AM3/18/20
to web...@googlegroups.com
Change 

db.posts.question by db.posts.message

Maurice Waka

unread,
Mar 18, 2020, 9:45:14 AM3/18/20
to web2py-users
Thanks.

This worked:

<div class="bottom_wrapper">
{{=form.custom.begin}}
<div class="row">
<div class="col-lg-8" >
{{=form.custom.widget.message}}
</div>
<div class="col-lg-4" >
{{=form.custom.submit}}
</div>
{{=form.custom.end}}
</div>
</div>

Reply all
Reply to author
Forward
0 new messages