diff --git a/resources/templates/form.tmpl b/resources/templates/form.tmpl index 93e4463..2718819 100644 --- a/resources/templates/form.tmpl +++ b/resources/templates/form.tmpl @@ -38,19 +38,19 @@ for a in sorted(attributes.keys(), key=lambda attr: attributes[attr]['weight']): ${attr['display_name']} % if modify and a == keyattr: - + ${tmp} % elif attr['type'] == 'string': - + % elif attr['type'] == 'email': - + % elif attr['type'] == 'int': - + % elif attr['type'] == 'fix': - + ${attr['value']} % elif attr['type'] == 'stringlist': - ${value2} %for val in attr['values']: @@ -74,3 +74,47 @@ ${form_col(lc1)} ${form_col(lc2)} +<% +from sets import Set +attr_set = Set([]) +attr_events = {} +functions = {} +for attrid in attributes: + attr = attributes[attrid] + field = 'attr.' + attrid + attr_set.add(field) + if 'autofill' in attr: + function = attr['autofill']['function'] + tuple = (field, function) + if not tuple in functions: + functions[tuple] = [] + for arg in attr['autofill']['args']: + if arg[0] == '$': + field_arg = 'attr.' + arg[1:] + attr_set.add(field_arg) + functions[tuple].append("fields['" + field_arg + "'].value") + if not field_arg in attr_events: + attr_events[field_arg] = [] + attr_events[field_arg].append(tuple) + else: + value = arg + functions[tuple].append("'" + value + "'") +%> +