Just as a forewarning the subject title is way more interesting than this post.
What functions are available inside a template inside a widget?
For example here is a snippet from the default TableForm widget's tempalte:
<tr py:for="i, field in enumerate(fields)"
class="${i%2 and 'odd' or 'even'}"
>
<th>
<label class="fieldlabel" for="${field.field_id}"
py:content="field.label" />
</th>
<td>
<span py:replace="field.display(value_for(field),
**params_for(field))" />
<span py:if="error_for(field)" class="fielderror"
py:content="error_for(field)" />
<span py:if="field.help_text" class="fieldhelp"
py:content="field.help_text" />
</td>
</tr>
Is there a way I can display fields by name instead of having to
iterate to them in the list? And where can I find out more about
value_for, params_for, error_for, etc.
Like something like this would be fantastic:
x = MyTableForm(..., fields = [TextField('firstName',...)],...)
class MyTableForm(TableForm):
template = """
...
<table>
<tr py:if="field_exists('firstName')">
<th><span py:replace="display_label_for('firstName')"/></th>
<td>
<span py:replace="display_field_for('firstName')"/>
<span py:replace="display_error_for('firstName')"/>
</td>
</tr>
</table>
..."""
-Ian
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---