Thank you for the quick response. Yeah I just made these template
functions to emulate the functionality I was looking for. The fact
that those take a string was really helpful I didn't realize that. I
also didn't realize there already was a display_field_for.
<span py:def="display_label_for(name)" py:strip="">
<label class="fieldlabel" for="${field_for(name).field_id}"
py:content="field_for(name).label" />
</span>
<span py:def="display_error_for(name)" py:strip="">
<span py:if="error_for(name)" class="fielderror"
py:content="error_for(name)" />
</span>
-ian
On 12/12/06, Alberto Valverde <[EMAIL PROTECTED]> wrote:
>
>
> > 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.
>
> Those functions accept both a widget instance and a widget name as a
> parameter, you can do:
>
> error_for('foo'), 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>
> > ..."""
>
> Looks nice, I'll take a look into it when I get a chance... (though
> patches are more than welcomed ;) BTW, "display_field_for" already
> exists... just in case you've missed it.
>
> 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?hl=en
-~----------~----~----~----~------~----~------~--~---