I have a table that follows the following structure: db.define_table('collection', Field('IssueYr', 'integer', requires = [IS_NOT_EMPTY(), IS_INT_IN_RANGE(1965,2018, "Not a valid year of issue")], widget = lambda f, v: SQLFORM.widgets.integer.widget(f, v, _autofocus=True)), Field('State', 'string', default=None, represent=lambda state: state or '', requires=IS_EMPTY_OR(IS_IN_SET(State_list))), Field('Other', 'string', default=None, represent=lambda Other: Other or '', requires=IS_EMPTY_OR(IS_IN_SET(other_list))) )
And I use use SQLFORM() to fill out the fields.. "State" is defined for certain issueYrs, for other years a javascript trigger skips to the "Other" field. This works well, and the State_list dropdown works as expected. But it turns out that the State_list can be subdivided with 4 or 5 corresponding to a given year. I do additional validation on the basis of this (to catch typo'd years). It would be nice to take advantage of that subdivision in the dropdown, only offering the, um, slice of states for the year that has been entered. For the validation, I have a dictionary where the keys are years and the values are the matching states. Is there a widget that I can pass the value-list to for use in the dropdown, using the javascript trigger to handle the key lookup? I looked at the autocomplete widget, and it's tied to a database field, so that's not very convenient for this use-case. I'm not totally against having essentially static tables when appropriate, but it seems like overkill for this. /dps -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.