There are two SingleSelectFields in a form, say Select2SingleSelectField1 and Select2SingleSelectField2. The values of both fields are retrieved from DB. The content of Select2SingleSelectField2 depends on the selected value of Select2SingleSelectField1.
In the controller how to capture the value of Select2SingleSelectField1? Could anyone help with this? Thanks.
I am using Turbogears 2.3.3 and Toscawidgets 2. There is no documentation about the parameters on Toscawidgets website. Nor is there on Turbogears website. The only piece of information is Toscawidgets 1's AutoCompleteField example http://turbogears.org/2.0/docs/main/ToscaWidgets/Cookbook/AutoComplete.html.
You can capture the event by setting the parameter completionURL.
from tw.jquery.autocomplete import AutoCompleteField
autoField = AutoCompleteField(
id='myFieldName',
completionURL = 'fetch_states',
fetchJSON = True,
minChars = 1)
It's not totally clear to me what's your situation as you stated you are using ToscaWidgets2 but your code example relates to
tw.jquery.autocompletewhich was from TW1 and your single select is named "Select2SingleSelectField", which makes me think that you are actually usingtw2.jqplugins.select2which has nothing to do withtw.jquery.autocompleteas it was implemented using jQueryUI and not Select2 :)As far as I can see
tw2.jqplugins.select2does not much apart wrapping the selection field with jQuery.select2 so the standard Select2 documentation applies as you can get a reference to the select2 from javascript and use as you normally would.Otherwise you might want to try axf.AjaxAutoCompleteField which has little bit more documentation (not much but at least there is an example) which is still implemented on Select2.
In any case both
tw2.jqplugins.select2andaxf.AjaxAutoCompleteFielddo not provide any particular support for depending from other fields (which in case of axf is provided byAjaxSingleSelectField) so on that part you will have to roll your own custom solution.