Does conversiontype need to be writable in forms? If not, you can use a
computed field. If you are just trying to change the default value, you
could do something like:
Field('conversiontype','reference conversiontype',
default=5 if request.vars.tiluse == 5 else 2)
Note, that will only change the default on submission, so it won't help
with pre-populating the form (but you can't know the value of tileuse at
the time the form is created anyway).
Anthony
On Thursday, September 5, 2013 7:32:04 PM UTC-4, greenpoise wrote:
>
> is it possible to have an if statement of some sort in Dal to validate/add
> a value based on other field?
>
> like:
>
> db.define_table('product',
> Field('series', 'reference series'),
> Field('suppliercode','reference supplier'),
> Field('description'),
> Field('tiluse','reference tileuse'),
> Field('price'),
> Field('cost'),
> Field('picture', 'upload'),
> Field('conversiontype','reference conversiontype',default=2))
>
>
>
> I need the conversiontype to be 1 if tiluse = '5' otherwise stay in 2.
> How can I accomplish this in Dal?
>
> thanks
>
--
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.