# HG changeset patch # User Sylvain Thénault # Date 1309364935 -7200 # Node ID bf9f8fa7e5dce5264dd55cb278bb3f72136f76c7 # Parent 328542c4fdc81007970f31e13deb7bae4306528f [form renderers] closes #1787232: new 'onerowtable' form renderer so it's easy to retrieve a dictionary of {field name : typed value} for a custom, no entity related, form diff -r 328542c4fdc8 -r bf9f8fa7e5dc web/data/cubicweb.css --- a/web/data/cubicweb.css Wed Jun 29 18:28:36 2011 +0200 +++ b/web/data/cubicweb.css Wed Jun 29 18:28:55 2011 +0200 @@ -819,21 +819,29 @@ background: %(listingHihligthedBgColor)s; } -table.htableForm { +table.htableForm label, table.oneRowTableForm label { vertical-align: middle; } - -table.htableForm td{ +table.htableForm td { padding-left: 1em; padding-top: 0.5em; } -table.htableForm th{ +table.htableForm th { padding-left: 1em; } table.htableForm .validateButton { margin-right: 0.2em; - vertical-align: top; - margin-bottom: 0.2em; /* because vertical-align doesn't seems to have any effect */ + margin-bottom: 0.2em; +} + +table.oneRowTableForm td { + padding-left: 0.5em; +} +table.oneRowTableForm th { + padding-left: 1em; +} +table.oneRowTableForm .validateButton { + margin: 0 0 0 1em ; } diff -r 328542c4fdc8 -r bf9f8fa7e5dc web/data/cubicweb.old.css --- a/web/data/cubicweb.old.css Wed Jun 29 18:28:36 2011 +0200 +++ b/web/data/cubicweb.old.css Wed Jun 29 18:28:55 2011 +0200 @@ -836,20 +836,29 @@ top: -1px; } -table.htableForm { +table.htableForm label, table.oneRowTableForm label { vertical-align: middle; } -table.htableForm td{ +table.htableForm td { padding-left: 1em; padding-top: 0.5em; } -table.htableForm th{ +table.htableForm th { padding-left: 1em; } table.htableForm .validateButton { margin-right: 0.2em; - vertical-align: top; - margin-bottom: 0.2em; /* because vertical-align doesn't seems to have any effect */ + margin-bottom: 0.2em; +} + +table.oneRowTableForm td { + padding-left: 0.5em; +} +table.oneRowTableForm th { + padding-left: 1em; +} +table.oneRowTableForm .validateButton { + margin: 0 0 0 1em ; } table.ajaxEditRelationTable{ diff -r 328542c4fdc8 -r bf9f8fa7e5dc web/views/formrenderers.py --- a/web/views/formrenderers.py Wed Jun 29 18:28:36 2011 +0200 +++ b/web/views/formrenderers.py Wed Jun 29 18:28:55 2011 +0200 @@ -335,6 +335,43 @@ pass +class OneRowTableFormRenderer(FormRenderer): + """The 'htable' form renderer display fields horizontally in a table: + + +--------------+--------------+--------------+--------------+---------+ + | field1 label | field1 input | field2 label | field2 input | buttons | + +--------------+--------------+--------------+--------------+---------+ + """ + __regid__ = 'onerowtable' + + display_help = False + def _render_fields(self, fields, w, form): + w(u'') + w(u'') + for field in fields: + if self.display_label: + w(u'' % self.render_label(form, field)) + if self.display_help: + w(self.render_help(form, field)) + error = form.field_error(field) + if error: + w(u'') + w(u'') + w(u'') + w(u'
%s') + self.render_error(w, error) + else: + w(u'') + w(field.render(form, self)) + w(u'') + for button in form.form_buttons: + w(button.render(form)) + w(u'
') + + def render_buttons(self, w, form): + pass + + class EntityCompositeFormRenderer(FormRenderer): """This is a specific renderer for the multiple entities edition form ('muledit').