Hello, I may ask something not realistic, I didn't think that much to this...
But I found my self, I would really need to know the value of another fields the than the field on which the widget is apply in other to init my widget correctly. I found a workaround that would be as easy as passing the value of those fields as a vars in the URL, but I feel that it is hacky compare to having acces to row from widget, like reprensent... Just to be more specific... I use this widget, from s-cubism sqlab : https://github.com/BuhtigithuB/sqlabs/blob/patch-1/modules/plugin_lazy_options_widget.py That I modify to fix issue with initialisation on update form... The thing is, that my fix is far from perfect, since the conditionnal field (the one on which the widget have been declared) is not filtered out, only the proper value for the conditionnal field is selected as it should on form update... So, I thougt, that I can fix this like that : Defining another _get_select_el function (maybe not required, but for now let use it) : def _get_select_el_for_init(self, trigger, value=None): if trigger: self._require.orderby = self.orderby or self._require.orderby self._require.dbset = self._require.dbset(self.where(trigger)) options = self._require.options() opts = [OPTION(v, _value=k) for (k, v) in options] return DIV(SELECT(_id='%s__aux' % self._el_id, value=value, _onchange='jQuery("#%s").val(jQuery(this).val());' % self._hidden_el_id, *opts)) else: return self.default Then I can do that : if value: el = DIV(script_el, SPAN(self._get_select_el_for_init(trigger=self.conditional_field_value, value=value), # SELECT(value=value, # _id='%s__aux' % self._el_id, # _onchange='jQuery("#%s").val(jQuery(this).val());' % self._hidden_el_id, # *[OPTION(v, _value=k) for (k, v) in field.requires.options()], # ), _id=self._disp_el_id), INPUT(_value=value, _type='hidden', _name=field.name, _id=self._hidden_el_id, requires=field.requires), _id=self._el_id) else: el = DIV(script_el, SPAN(select_el or self.default, _id=self._disp_el_id), INPUT(_value=value, _type='hidden', _name=field.name, _id=self._hidden_el_id, requires=field.requires), _id=self._el_id) Instead of what is commented out... self.conditional_field_value contain the id selected in the "master" field. It would requires that I could do something like that : widget=lambda field, value, row: lazy_options_widget(field=field, on_key='no_table_master_field__selected', off_key='master_field__unselected', where=lambda master_field: (db.lookuptable.master_field == row.master_field ), trigger=request.vars.master_field, orderby=db.lookuptable.id, ... ) Does it make any sens or what? I can just do that instead : if value: el = DIV(script_el, SPAN(self._get_select_el_for_init(trigger= *current.request.vars.conditional_field_value*, value=value), # SELECT(value=value, # _id='%s__aux' % self._el_id, # _onchange='jQuery("#%s").val(jQuery(this).val());' % self._hidden_el_id, # *[OPTION(v, _value=k) for (k, v) in field.requires.options()], # ), _id=self._disp_el_id), INPUT(_value=value, _type='hidden', _name=field.name, _id=self._hidden_el_id, requires=field.requires), _id=self._el_id) And passing the vars into the URL... Thanks Richard -- 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/groups/opt_out.