equal
deleted
inserted
replaced
108 class FieldWidget(object): |
108 class FieldWidget(object): |
109 """The abstract base class for widgets. |
109 """The abstract base class for widgets. |
110 |
110 |
111 **Attributes** |
111 **Attributes** |
112 |
112 |
113 Here are standard attributes of a widget, that may be set on concret |
113 Here are standard attributes of a widget, that may be set on concrete class |
114 class to override default behaviours: |
114 to override default behaviours: |
115 |
115 |
116 :attr:`needs_js` |
116 :attr:`needs_js` |
117 list of javascript files needed by the widget. |
117 list of javascript files needed by the widget. |
118 |
118 |
119 :attr:`needs_css` |
119 :attr:`needs_css` |
132 :attr:`vocabulary_widget` |
132 :attr:`vocabulary_widget` |
133 flag telling if this widget expect a vocabulary |
133 flag telling if this widget expect a vocabulary |
134 |
134 |
135 Also, widget instances takes as first argument a `attrs` dictionary which |
135 Also, widget instances takes as first argument a `attrs` dictionary which |
136 will be stored in the attribute of the same name. It contains HTML |
136 will be stored in the attribute of the same name. It contains HTML |
137 attributes that should be set in the widget's input tag (though concret |
137 attributes that should be set in the widget's input tag (though concrete |
138 classes may ignore it). |
138 classes may ignore it). |
139 |
139 |
140 .. currentmodule:: cubicweb.web.formwidgets |
140 .. currentmodule:: cubicweb.web.formwidgets |
141 |
141 |
142 **Form generation methods** |
142 **Form generation methods** |
188 """ |
188 """ |
189 self.add_media(form) |
189 self.add_media(form) |
190 return self._render(form, field, renderer) |
190 return self._render(form, field, renderer) |
191 |
191 |
192 def _render(self, form, field, renderer): |
192 def _render(self, form, field, renderer): |
193 """This is the method you have to implement in concret widget classes. |
193 """This is the method you have to implement in concrete widget classes. |
194 """ |
194 """ |
195 raise NotImplementedError() |
195 raise NotImplementedError() |
196 |
196 |
197 def format_value(self, form, field, value): |
197 def format_value(self, form, field, value): |
198 return field.format_value(form._cw, value) |
198 return field.format_value(form._cw, value) |
230 Values found in 1. and 2. are expected te be already some 'display |
230 Values found in 1. and 2. are expected te be already some 'display |
231 value' (eg a string) while those found in 3. and 4. are expected to be |
231 value' (eg a string) while those found in 3. and 4. are expected to be |
232 correctly typed value. |
232 correctly typed value. |
233 |
233 |
234 3 and 4 are handle by the :meth:`typed_value` method to ease reuse in |
234 3 and 4 are handle by the :meth:`typed_value` method to ease reuse in |
235 concret classes. |
235 concrete classes. |
236 """ |
236 """ |
237 values = None |
237 values = None |
238 if not field.ignore_req_params: |
238 if not field.ignore_req_params: |
239 qname = field.input_name(form, self.suffix) |
239 qname = field.input_name(form, self.suffix) |
240 # value from a previous post that has raised a validation error |
240 # value from a previous post that has raised a validation error |