def render(self, value, vars, attributes): options = get_options(attributes.get("options", "[options]")) if isinstance(value, (list, tuple)): values = [_str(v) for v in value] else: values = [_str(value)] options = [(k, v) for k, v in options if k != ''] opts = [] cols = attributes.get('cols', self.DEFAULT_CONFIGURE["cols"]) totals = len(options) mods = totals % cols rows = totals / cols if mods: rows += 1 for r_index in range(rows): tds = [] for k, v in options[r_index*cols:(r_index+1)*cols]: if k in values: r_value = k else: r_value = [] tds.append(TD(INPUT(_type='radio', _name=attributes["fieldname"], _value=k, value=r_value), v)) opts.append(TR(tds)) return TABLE(*opts)
def render(self, value, vars, attributes): options = get_options(attributes.get("options", "[options]")) options = [(k, v) for k, v in options] opts = [] for k, v in options: attr = {} if k in ("", None): attr = {"_disabled":"disabled"} else: attr = {"_value":k} opts.append(OPTION(v, **attr)) attr = {"_name":attributes["fieldname"], "_id":"%(tablename)s_%(fieldname)s"%attributes, "value":value} if isinstance(value, (list, tuple)) and attributes.get("maxlen", 0)>0: attr["_multiple"] = "multiple" return SELECT(*opts, **attr)