56 self.add_media(form) |
56 self.add_media(form) |
57 return self._render(form, field, renderer) |
57 return self._render(form, field, renderer) |
58 |
58 |
59 def _render(self, form, field, renderer): |
59 def _render(self, form, field, renderer): |
60 raise NotImplementedError() |
60 raise NotImplementedError() |
61 |
|
62 def typed_value(self, form, field): |
|
63 """return field's *typed* value specified in: |
|
64 3. extra form values given to render() |
|
65 4. field's typed value |
|
66 """ |
|
67 qname = field.input_name(form) |
|
68 for key in (field, qname): |
|
69 try: |
|
70 return form.formvalues[key] |
|
71 except KeyError: |
|
72 continue |
|
73 if field.name != qname and field.name in form.formvalues: |
|
74 return form.formvalues[field.name] |
|
75 return field.typed_value(form) |
|
76 |
61 |
77 def format_value(self, form, field, value): |
62 def format_value(self, form, field, value): |
78 return field.format_value(form._cw, value) |
63 return field.format_value(form._cw, value) |
79 |
64 |
80 def values_and_attributes(self, form, field): |
65 def values_and_attributes(self, form, field): |
115 if values != INTERNAL_FIELD_VALUE: |
100 if values != INTERNAL_FIELD_VALUE: |
116 values = self.format_value(form, field, values) |
101 values = self.format_value(form, field, values) |
117 if not isinstance(values, (tuple, list)): |
102 if not isinstance(values, (tuple, list)): |
118 values = (values,) |
103 values = (values,) |
119 return values |
104 return values |
|
105 |
|
106 def typed_value(self, form, field): |
|
107 """return field's *typed* value specified in: |
|
108 3. extra form values given to render() |
|
109 4. field's typed value |
|
110 """ |
|
111 qname = field.input_name(form) |
|
112 for key in ((field, form), qname): |
|
113 try: |
|
114 return form.formvalues[key] |
|
115 except KeyError: |
|
116 continue |
|
117 if field.name != qname and field.name in form.formvalues: |
|
118 return form.formvalues[field.name] |
|
119 return field.typed_value(form) |
120 |
120 |
121 def process_field_data(self, form, field): |
121 def process_field_data(self, form, field): |
122 posted = form._cw.form |
122 posted = form._cw.form |
123 val = posted.get(field.input_name(form, self.suffix)) |
123 val = posted.get(field.input_name(form, self.suffix)) |
124 if isinstance(val, basestring): |
124 if isinstance(val, basestring): |