[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
--- 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 ;
}
--- 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{
--- 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'<table border="0" class="oneRowTableForm">')
+ w(u'<tr>')
+ for field in fields:
+ if self.display_label:
+ w(u'<th class="labelCol">%s</th>' % self.render_label(form, field))
+ if self.display_help:
+ w(self.render_help(form, field))
+ error = form.field_error(field)
+ if error:
+ w(u'<td class="error">')
+ self.render_error(w, error)
+ else:
+ w(u'<td>')
+ w(field.render(form, self))
+ w(u'</td>')
+ w(u'<td>')
+ for button in form.form_buttons:
+ w(button.render(form))
+ w(u'</td>')
+ w(u'</tr>')
+ w(u'</table>')
+
+ def render_buttons(self, w, form):
+ pass
+
+
class EntityCompositeFormRenderer(FormRenderer):
"""This is a specific renderer for the multiple entities edition form
('muledit').