I'm having some trouble with widgets, and I wanted to double check
that my methods aren't wrong before submitting a ticket.

I'm currently using the AutoCompleteField and CalendarDatePicker
widgets.  If I create them "standalone" and insert them one by one in
my template, everything is fine:

==Controller==

def index(self):

    contact_to = widgets.AutoCompleteField(name="contact_to",
labeltext="To", search_controller=turbogears.url("/contactsearch"))

    start_date = widgets.CalendarDatePicker(name="start_date",
labeltext="Start Date", format="%d/%m/%Y")

    return dict(contact_to=contact_to, start_date=start_date)


==Template Snippet==

<form>
    <span py:replace="contact_to.insert()"></span>
    <span py:replace="start_date.insert()"></span>
</form>


With this method I get the appropriate JS and CSS links in my <head> tags.

If I do the following however:

==Controller==

def index(self):
    page_widgets = [widgets.AutoCompleteField(<snip>),
                widgets.CalendarDatePicker(<snip>)]

    return dict(page_widgets=page_widgets)

==Template Snippet==

<form>
    <span py:for="widget in page_widgets" py:replace="widget.insert()"></span>
</form>

The above set of code does not work.  The widgets are rendered, but
the associated JS and CSS links are nowhere to be found.  The same
symptom occurs if using a FieldSet widget and I assume the same could
be said for a TableForm (although I haven't tested that).

Is there something I should be doing if a bunch of widgets are being
iterated over?  I can't see from the code that there should be.

I'm using Revision 497 of the trunk.

Thanks,

Lee

Reply via email to