override default model values in SQLFORM

154 views
Skip to first unread message

David Zejda

unread,
Jul 3, 2009, 2:16:02 PM7/3/09
to web...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

I have table with a "subject" field, with default value specified in model.

Now I would like to generate forms to add and update records.
In the forms the default value specified in the model has to be
overriden on certain conditions.

I tried these:

form.vars.subject = "another default value"

form.custom.dspval.subject = "another default value"

form.custom.inpval.subject = "another default value"

But none of them works, still there are model default values filled in
the form fields.

Please, could you help?

Thanks in advance..

David
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpOSuIACgkQ3oCkkciamVGjGACeNxJre32E0Kg60BDZCSC3LG1E
gL0An2cy1fws0OaHvhaIkBrnNN5WgYSZ
=zZus
-----END PGP SIGNATURE-----

mdipierro

unread,
Jul 3, 2009, 2:25:27 PM7/3/09
to web2py Web Framework
No you just do

db.table.field.default = "another default value"

before SQLFORM or before crud.update

On Jul 3, 1:16 pm, David Zejda <d...@atlas.cz> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello,
>
> I have table with a "subject" field, with default value specified in model.
>
> Now I would like to generate forms to add and update records.
> In the forms the default value specified in the model has to be
> overriden on certain conditions.
>
> I tried these:
>
> form.vars.subject = "another default value"
>
> form.custom.dspval.subject = "another default value"
>
> form.custom.inpval.subject = "another default value"
>
> But none of them works, still there are model default values filled in
> the form fields.
>
> Please, could you help?
>
> Thanks in advance..
>
> David
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org

David Zejda

unread,
Jul 10, 2009, 9:14:25 AM7/10/09
to web...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Please, do you have any advices?

David Zejda napsal(a):


> Hello,
>
> I have table with a "subject" field, with default value specified in model.
>
> Now I would like to generate forms to add and update records.
> In the forms the default value specified in the model has to be
> overriden on certain conditions.
>
> I tried these:
>
> form.vars.subject = "another default value"
>
> form.custom.dspval.subject = "another default value"
>
> form.custom.inpval.subject = "another default value"
>

> But none of them works, still there are model default values pre-filled in


> the form fields.
>
> Please, could you help?
>
> Thanks in advance..
>
> David
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpXPrEACgkQ3oCkkciamVGzkACgo5qrBcRjdXm975QkirF85B9F
qOAAoIaIojQTG4Jfx2bhdet7Hx0VzQMz
=02Cn
-----END PGP SIGNATURE-----

Hans Donner

unread,
Jul 10, 2009, 9:23:09 AM7/10/09
to web...@googlegroups.com

David Zejda

unread,
Jul 20, 2009, 5:45:38 PM7/20/09
to web...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Oh sorry, I just overlooked the initial reply.. :o)

Hans Donner napsal(a):

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpk5YEACgkQ3oCkkciamVFtJwCdE1ARh9teph1nzhtN70gdKWXU
sNQAoJ3lEgXwgGCidr4wpnAmKleyc3UA
=DlnB
-----END PGP SIGNATURE-----

Reply all
Reply to author
Forward
0 new messages