Ignore:
Timestamp:
11 Mar 2011, 23:48:45 (14 years ago)
Author:
uli
Message:

Enable jQuery datepicker in a form (where we, in contrast to views or
pages, do not render HTML ourselves but use widgets for that job).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py

    r5843 r5844  
    2828from hurry.jqueryui import jqueryui
    2929from zope.component import getUtility, getAllUtilitiesRegisteredFor
    30 from zope.formlib.widgets import FileWidget
     30from zope.formlib.widgets import FileWidget, DateWidget
    3131from waeup.sirp.browser import (
    3232    WAeUPPage, WAeUPEditFormPage, WAeUPAddFormPage,
     
    7272    MultiListDisplayWidget, subwidget=results_display_widget)
    7373
     74#: A date widget that renders with CSS class `datepicker` thus
     75#  enabling : the jQuery datepicker for this field if the form loaded
     76#  the jQuery code.
     77FriendlyDateWidget = CustomWidgetFactory(
     78    DateWidget, cssClass='datepicker')
     79
    7480class ApplicationsPage(WAeUPPage):
    7581    grok.context(IApplicantsRoot)
     
    287293    grok.name('edit')
    288294    form_fields = grok.AutoFields(IApplicantsContainer)
     295    # Use friendlier date widget...
     296    form_fields['startdate'].custom_widget = FriendlyDateWidget
     297    form_fields['enddate'].custom_widget = FriendlyDateWidget
    289298    label = 'Edit container'
    290299    title = label
Note: See TracChangeset for help on using the changeset viewer.