Hi Keith,
Right now this cannot be done, I think it should but just didn't get on
time ;)
This patch:
Index: turbogears/widgets/forms.py
===================================================================
--- turbogears/widgets/forms.py (revision 852)
+++ turbogears/widgets/forms.py (working copy)
@@ -541,6 +541,8 @@
d['hidden_fields'] = hidden_fields
d['submit'] = self.widgets['submit']
d["submit_text"] = d.get("submit_text", None)
+ d["field_for"] = self.field_for
+ d["error_for"] = lambda name: d["form_errors"].get(name)
return d
Should allow you to do something like this:
class MyForm(widgets.Form):
template = """
<form xmlns:py="http://purl.org/kid/ns#"
name="${name}"
py:attrs="form_attrs"
>
<table border="0">
<tr>
<td>${field_for("name").display()}</td>
<td>${field_for("age").display()}</td>
</tr>
<tr>
<td>${error_for("name")}</td>
<td>${error_for("age")}</td>
</tr>
</table>
</form>
"""
If you don't feel like patching you can achive the same thing by:
class MyForm(widgets.Form):
def update_data(self, d):
super(MyForm, slef).update_data(d)
d["field_for"] = self.field_for
d["error_for"] = lambda name: d["form_errors"].get(name)
and using this as a super class for any form you want to use field_for
and error_for in the template.
There's still work to do regarding the field label and help_text, but
should be a start. I think something on this line should be desirable
default behaviour and get into the trunk... Opinions?
Hope it helps, Alberto
Alberto
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---