At 06:09 PM 1/15/2003 -0500, Neil Schemenauer wrote:
>How are you reassigning the values?
In the end, the hack that worked involved calling render again, from
process -- if the OptionSelectWidget onchange() event happens,
submit_button is "", so a re-render et voila.
Not sure if that's working as designed or intended but it works. In my case
I needed to re-render the same fields but with different values, one of
which is the language value from the OptionSelectWidget.
def process (self, request):
# check so see if we are here as a result of the OptionSelect widget
# submit will be "" if it was used as opposed to the "update"
# "delete" or "add" buttons being selected
submit = self.get_submit_button(request)
if request.form and submit == "":
return self.render(request, 'details') #hard coded hack for now
form_data = ParlezForm.process(self, request)
# snip various tests
return form_data
>The main trick to understanding
>OptionSelectWidget is to realize that widgets only use the supplied
>value when the form is initially rendered. If the form is submitted
>then the values for widgets come from the request (if there is a value
>for that widget in the request).
It took a bit of churning before I realized that widget values were only
set for the initial render. Playing with widgets outside of form made it a
bit easier to understand what I was missing.
>Look at HiddenWidget.set_current_value() for an example of how to set
>the value and override what is in the request. It would be nice if
>there was method that worked on all widgets. Maybe we could add a
>"force" keyword to set_value.
>
>In any case, OptionSelectWidget is tricky.
Thanks for the tip.