it worked w quotes on..couldnt tell you which is right though   



On Friday, September 6, 2013 10:03:40 AM UTC-7, Anthony wrote:
>
> Probably should remove the quotes from the 2, no?
>
> On Friday, September 6, 2013 12:59:36 PM UTC-4, greenpoise wrote:
>>
>> Ended up using lambda instead. 
>>
>> Field('conversiontype','reference conversiontype',compute=lambda r: 1 
>> ifrequest
>> .vars.tileuse == '5' else '2'),
>>
>>
>> Thanks!
>>
>>
>>
>> On Thursday, September 5, 2013 7:25:32 PM UTC-7, greenpoise wrote:
>>>
>>> Thats exactly what I am looking! Thanks, will try and post Thanks Anthony
>>>
>>>
>>>
>>> On Thursday, September 5, 2013 6:31:46 PM UTC-7, Anthony wrote:
>>>>
>>>> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to