web/views/formrenderers.py
changeset 3396 fb261afd49cd
parent 3388 b8be8fc77c27
parent 3377 dd9d292b6a6d
child 3398 d84b0176452c
equal deleted inserted replaced
3395:405f393bcac0 3396:fb261afd49cd
    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')
   242 
   242 
   243 class BaseFormRenderer(FormRenderer):
   243 class BaseFormRenderer(FormRenderer):
   244     """use form_renderer_id = 'base' if you want base FormRenderer layout even
   244     """use form_renderer_id = 'base' if you want base FormRenderer layout even
   245     when selected for an entity
   245     when selected for an entity
   246     """
   246     """
   247     id = 'base'
   247     __regid__ = 'base'
   248 
   248 
   249 
   249 
   250 class EntityBaseFormRenderer(BaseFormRenderer):
   250 class EntityBaseFormRenderer(BaseFormRenderer):
   251     """use form_renderer_id = 'base' if you want base FormRenderer layout even
   251     """use form_renderer_id = 'base' if you want base FormRenderer layout even
   252     when selected for an entity
   252     when selected for an entity
   269     | field1 label | field2 label |         |
   269     | field1 label | field2 label |         |
   270     +--------------+--------------+---------+
   270     +--------------+--------------+---------+
   271     | field1 input | field2 input | buttons
   271     | field1 input | field2 input | buttons
   272     +--------------+--------------+---------+
   272     +--------------+--------------+---------+
   273     """
   273     """
   274     id = 'htable'
   274     __regid__ = 'htable'
   275 
   275 
   276     display_help = False
   276     display_help = False
   277     def _render_fields(self, fields, w, form):
   277     def _render_fields(self, fields, w, form):
   278         w(u'<table border="0">')
   278         w(u'<table border="0">')
   279         w(u'<tr>')
   279         w(u'<tr>')
   306         pass
   306         pass
   307 
   307 
   308 
   308 
   309 class EntityCompositeFormRenderer(FormRenderer):
   309 class EntityCompositeFormRenderer(FormRenderer):
   310     """specific renderer for multiple entities edition form (muledit)"""
   310     """specific renderer for multiple entities edition form (muledit)"""
   311     id = 'composite'
   311     __regid__ = 'composite'
   312 
   312 
   313     _main_display_fields = None
   313     _main_display_fields = None
   314 
   314 
   315     def render_fields(self, w, form, values):
   315     def render_fields(self, w, form, values):
   316         if not form.is_subform:
   316         if not form.is_subform:
   366             self._main_display_fields = fields
   366             self._main_display_fields = fields
   367 
   367 
   368 
   368 
   369 class EntityFormRenderer(EntityBaseFormRenderer):
   369 class EntityFormRenderer(EntityBaseFormRenderer):
   370     """specific renderer for entity edition form (edition)"""
   370     """specific renderer for entity edition form (edition)"""
   371     id = 'default'
   371     __regid__ = 'default'
   372     # needs some additional points in some case (XXX explain cases)
   372     # needs some additional points in some case (XXX explain cases)
   373     __select__ = EntityBaseFormRenderer.__select__ & yes()
   373     __select__ = EntityBaseFormRenderer.__select__ & yes()
   374 
   374 
   375     _options = FormRenderer._options + ('display_relations_form',)
   375     _options = FormRenderer._options + ('display_relations_form',)
   376     display_relations_form = True
   376     display_relations_form = True
   526 
   526 
   527 class EntityInlinedFormRenderer(EntityFormRenderer):
   527 class EntityInlinedFormRenderer(EntityFormRenderer):
   528     """specific renderer for entity inlined edition form
   528     """specific renderer for entity inlined edition form
   529     (inline-[creation|edition])
   529     (inline-[creation|edition])
   530     """
   530     """
   531     id = 'inline'
   531     __regid__ = 'inline'
   532 
   532 
   533     def render(self, form, values):
   533     def render(self, form, values):
   534         form.add_media()
   534         form.add_media()
   535         data = []
   535         data = []
   536         w = data.append
   536         w = data.append