web/formwidgets.py
branchstable
changeset 2091 a7ea618e5478
parent 1989 8c8dead642f7
child 2131 00e6d1cb18ea
equal deleted inserted replaced
2090:089d1705c89c 2091:a7ea618e5478
    20     needs_js = ()
    20     needs_js = ()
    21     needs_css = ()
    21     needs_css = ()
    22     # automatically set id and tabindex attributes ?
    22     # automatically set id and tabindex attributes ?
    23     setdomid = True
    23     setdomid = True
    24     settabindex = True
    24     settabindex = True
       
    25     # does this widget expect a vocabulary
       
    26     vocabulary_widget = False
    25 
    27 
    26     def __init__(self, attrs=None, setdomid=None, settabindex=None):
    28     def __init__(self, attrs=None, setdomid=None, settabindex=None):
    27         if attrs is None:
    29         if attrs is None:
    28             attrs = {}
    30             attrs = {}
    29         self.attrs = attrs
    31         self.attrs = attrs
   169         return super(FCKEditor, self).render(form, field)
   171         return super(FCKEditor, self).render(form, field)
   170 
   172 
   171 
   173 
   172 class Select(FieldWidget):
   174 class Select(FieldWidget):
   173     """<select>, for field having a specific vocabulary"""
   175     """<select>, for field having a specific vocabulary"""
       
   176     vocabulary_widget = True
       
   177 
   174     def __init__(self, attrs=None, multiple=False):
   178     def __init__(self, attrs=None, multiple=False):
   175         super(Select, self).__init__(attrs)
   179         super(Select, self).__init__(attrs)
   176         self._multiple = multiple
   180         self._multiple = multiple
   177 
   181 
   178     def render(self, form, field):
   182     def render(self, form, field):
   201 class CheckBox(Input):
   205 class CheckBox(Input):
   202     """<input type='checkbox'>, for field having a specific vocabulary. One
   206     """<input type='checkbox'>, for field having a specific vocabulary. One
   203     input will be generated for each possible value.
   207     input will be generated for each possible value.
   204     """
   208     """
   205     type = 'checkbox'
   209     type = 'checkbox'
       
   210     vocabulary_widget = True
   206 
   211 
   207     def render(self, form, field):
   212     def render(self, form, field):
   208         name, curvalues, attrs = self._render_attrs(form, field)
   213         name, curvalues, attrs = self._render_attrs(form, field)
   209         domid = attrs.pop('id', None)
   214         domid = attrs.pop('id', None)
   210         sep = attrs.pop('separator', u'<br/>')
   215         sep = attrs.pop('separator', u'<br/>')