py4web - form field default - appears to not be working for me

69 views
Skip to first unread message

Jim S

unread,
Jan 21, 2020, 9:27:02 PM1/21/20
to web2py-users
Sorry for all the py4web noob questions

I have the following:

    search_text = 'test'
    form
= Form([Field('search',
                       length
=50,
                       
default=search_text)],
                form_name
='search_form',
                formstyle
=FormStyleBulma,
                keep_values
=True)

I can't get the default search_text to appear in the field. 

Anything obvious I'm missing?

-Jim

Massimo Di Pierro

unread,
Jan 22, 2020, 1:20:52 AM1/22/20
to web2py-users
can you try this?

form = Form(....)
if not form.submitted: form.vars.update({field.name:field.default for field in form.table if field.default})

Maybe I can make this default behavior?

Jim Steil

unread,
Jan 22, 2020, 8:46:10 AM1/22/20
to web...@googlegroups.com
Yes, that did the trick!

Thanks Massimo

--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/Snj3R2aVOfc/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/e9ea15c4-d6a4-44de-a13b-d54e2d0e606c%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages