How to set the 'value' parameter for a hidden field in runtime in Turbogears

337 Views Asked by At

In order to set the value for a HiddenField in toscawidget, the only parameter I've found useful is 'default' (surprisingly, parameter 'value' in toscawidgets doesn't represent 'value' in html). However, the only way I could get it working is at the time of field creation:

class myForm(TableForm):
    class fields(WidgetsList): 
    myhiddenField = HiddenField(default='old_value')

However, I need to be filled in runtime, or in other words, I want my controller to change the value of the hidden field in runtime. but it seems impossible, and

child_args=dict(myHiddenField = dict(default = 'new_value'))

doesnt seem to be working.

1

There are 1 best solutions below

0
On

Normally, it should be sufficient to supply the value in the options dict when you render the form in your template.

myform(dict(myHiddenField=dict(default='new_value')))

No need for child_args here.