On Friday 05 May 2006 14:34, Roger Rohrbach wrote:
> I'm really lazy.  I want to avoid writing a custom form, but I want to
> include a checkbox whose label is laid out immediately after the input
> widget.

Well, I've done both - a custom form which displays labels and widget in a 
linear fashion (labels set in CSS to be block elements and thus on their own 
line) and customized checkbox to have a "caption" in addition to its label.


class StandardCheckBox(CheckBox):
        template = """
<div xmlns:py="http://purl.org/kid/ns#";>
        """ + CheckBox.template + """
        <label class="caption" for="${field_id}">${caption}</label>
</div>
"""
        params = ["caption"]
        caption = ""


class SimpleForm(Form):
        template = """
<form xmlns:py="http://purl.org/kid/ns#";
        name="${name}"
        action="${action}"
        method="${method}"
        py:attrs="form_attrs">
        <div py:for="field in hidden_fields" 
                py:replace="field.display(value_for(field), 
**params_for(field))" />
        <div py:for="i, field in enumerate(fields)"
                        class="${i%2 and 'odd' or 'even'}">
                <label class="fieldlabel" for="${field.field_id}" 
py:content="field.label" />
                <div py:if="field.help_text" class="fieldhelp" 
py:content="field.help_text" />
                <div py:replace="field.display(value_for(field), 
**params_for(field))" />
                <div py:if="error_for(field)" class="fielderror" 
py:content="error_for(field)" />
        </div>
        <div style="margin-top: 10px;">
                ${submit()}
        </div>
</form>
"""

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to