web/views/formrenderers.py
changeset 3377 dd9d292b6a6d
parent 3369 7b88d12b4ee2
child 3396 fb261afd49cd
equal deleted inserted replaced
3376:f5c69485381f 3377:dd9d292b6a6d
    37     +---------+
    37     +---------+
    38     | buttons |
    38     | buttons |
    39     +---------+
    39     +---------+
    40     """
    40     """
    41     __registry__ = 'formrenderers'
    41     __registry__ = 'formrenderers'
    42     id = 'default'
    42     __regid__ = 'default'
    43 
    43 
    44     _options = ('display_fields', 'display_label', 'display_help',
    44     _options = ('display_fields', 'display_label', 'display_help',
    45                 'display_progress_div', 'table_class', 'button_bar_class',
    45                 'display_progress_div', 'table_class', 'button_bar_class',
    46                 # add entity since it may be given to select the renderer
    46                 # add entity since it may be given to select the renderer
    47                 'entity')
    47                 'entity')
   244 
   244 
   245 class BaseFormRenderer(FormRenderer):
   245 class BaseFormRenderer(FormRenderer):
   246     """use form_renderer_id = 'base' if you want base FormRenderer layout even
   246     """use form_renderer_id = 'base' if you want base FormRenderer layout even
   247     when selected for an entity
   247     when selected for an entity
   248     """
   248     """
   249     id = 'base'
   249     __regid__ = 'base'
   250 
   250 
   251 
   251 
   252 class EntityBaseFormRenderer(BaseFormRenderer):
   252 class EntityBaseFormRenderer(BaseFormRenderer):
   253     """use form_renderer_id = 'base' if you want base FormRenderer layout even
   253     """use form_renderer_id = 'base' if you want base FormRenderer layout even
   254     when selected for an entity
   254     when selected for an entity
   273     | field1 label | field2 label |         |
   273     | field1 label | field2 label |         |
   274     +--------------+--------------+---------+
   274     +--------------+--------------+---------+
   275     | field1 input | field2 input | buttons
   275     | field1 input | field2 input | buttons
   276     +--------------+--------------+---------+
   276     +--------------+--------------+---------+
   277     """
   277     """
   278     id = 'htable'
   278     __regid__ = 'htable'
   279 
   279 
   280     display_help = False
   280     display_help = False
   281     def _render_fields(self, fields, w, form):
   281     def _render_fields(self, fields, w, form):
   282         w(u'<table border="0">')
   282         w(u'<table border="0">')
   283         w(u'<tr>')
   283         w(u'<tr>')
   310         pass
   310         pass
   311 
   311 
   312 
   312 
   313 class EntityCompositeFormRenderer(FormRenderer):
   313 class EntityCompositeFormRenderer(FormRenderer):
   314     """specific renderer for multiple entities edition form (muledit)"""
   314     """specific renderer for multiple entities edition form (muledit)"""
   315     id = 'composite'
   315     __regid__ = 'composite'
   316 
   316 
   317     _main_display_fields = None
   317     _main_display_fields = None
   318 
   318 
   319     def render_fields(self, w, form, values):
   319     def render_fields(self, w, form, values):
   320         if not form.is_subform:
   320         if not form.is_subform:
   370             self._main_display_fields = fields
   370             self._main_display_fields = fields
   371 
   371 
   372 
   372 
   373 class EntityFormRenderer(EntityBaseFormRenderer):
   373 class EntityFormRenderer(EntityBaseFormRenderer):
   374     """specific renderer for entity edition form (edition)"""
   374     """specific renderer for entity edition form (edition)"""
   375     id = 'default'
   375     __regid__ = 'default'
   376     # needs some additional points in some case (XXX explain cases)
   376     # needs some additional points in some case (XXX explain cases)
   377     __select__ = EntityBaseFormRenderer.__select__ & yes()
   377     __select__ = EntityBaseFormRenderer.__select__ & yes()
   378 
   378 
   379     _options = FormRenderer._options + ('display_relations_form',)
   379     _options = FormRenderer._options + ('display_relations_form',)
   380     display_relations_form = True
   380     display_relations_form = True
   530 
   530 
   531 class EntityInlinedFormRenderer(EntityFormRenderer):
   531 class EntityInlinedFormRenderer(EntityFormRenderer):
   532     """specific renderer for entity inlined edition form
   532     """specific renderer for entity inlined edition form
   533     (inline-[creation|edition])
   533     (inline-[creation|edition])
   534     """
   534     """
   535     id = 'inline'
   535     __regid__ = 'inline'
   536 
   536 
   537     def render(self, form, values):
   537     def render(self, form, values):
   538         form.add_media()
   538         form.add_media()
   539         data = []
   539         data = []
   540         w = data.append
   540         w = data.append